Open sandboxFocusImprove this doc

LA0118: Aspect Class Is Not Serializable on a Platform Without Serialization

Severity Error
Reported by PostSharp
Message Aspect type "<AspectType>" must be annotated with [PSerializable].

Cause

PostSharp creates the aspect instances at build time and serializes them into the assembly. It uses the SerializerType of the configuration of the aspect when it is set, and otherwise the PostSharp serializer, when the aspect class has the [PSerializableAttribute] attribute.

When the aspect class has neither, PostSharp checks whether the target framework of the project supports the binary serialization of .NET. PostSharp reports LA0118, on the aspect class <AspectType>, when it does not: for example on .NET Standard 1.x, .NET Core 1.x, portable class libraries, UWP and Xamarin. On .NET Framework, .NET Standard 2.0 and later, and .NET Core 2.0 and later, PostSharp reports LA0119 instead.

This message depends on a target framework that the test projects of this documentation do not target, so no example can show it. LA0119 shows the same mistake on .NET.

Resolution

See Also

Reference

PSerializableAttribute
MsilAspectSerializer
SerializerType

Other Resources

Understanding Aspect Serialization