Can Reflection be used in CompileTimeInitialize in PostSharp 3.1?-Collection of common programming errors

You can use reflection in CompileTimeInitialize method and, actually, locationInfo holds correct information during that method’s execution.

However, the locationInfo field is then serialized, and later deserialized during runtime. This is where the problem happens – apparently, version 3.1 has introduced a bug related to serialization in this particular case. You can check this by saving only locationInfo.Name in the field, for example.

It means you’d need to wait for a bug fix to be implemented in 3.1. You may also want to report the bugs directly on the PostSharp support forum.