Open sandboxFocusImprove this doc

LA0157: Serializable Aspect in an Assembly Not Processed by PostSharp

Severity Error
Reported by PostSharp
Message The aspect type "<AspectType>" has the [PSerializable] custom attribute, but its assembly "<AssemblyPath>" has not been processed by PostSharp. Make sure the assembly is processed by PostSharp.

Cause

PostSharp instantiates your aspects at build time, then serializes them into the assembly that uses them, and deserializes them at run time. An aspect with the PSerializableAttribute custom attribute relies on a serializer that PostSharp generates when it processes the assembly that defines the aspect.

When the aspect is defined in a referenced assembly that PostSharp has not processed, typically a library project that does not reference the PostSharp package, the serializer does not exist, and PostSharp reports LA0157 when it weaves the assembly that uses the aspect. <AssemblyPath> is the full path of the assembly that defines the aspect.

The same cause also makes PostSharp report the warning LA0036, because the optimization information of the methods of the aspect is also computed when PostSharp processes its assembly.

The message contains the full path of an assembly on the build machine, so this article has no example.

Resolution

Add the PostSharp package to the project that defines the aspect, so that PostSharp processes its assembly. Every assembly that defines aspects must be processed by PostSharp, even when it applies none of them.

See Also

Reference

PSerializableAttribute

Other Resources

Understanding Aspect Serialization