I have written an aspect implementing IInstanceScopedAspect
and inheriting from LocationInterceptionAspect.
When initialized, it reads some properties from the target object. The problem is that IInstanceScopedAspect.RuntimeInitializeInstance()
is called before the target object's constructors have run. So the target object is not fully initialized and reading its properties leads to all kinds of nasty behavior.
How can I be notified when the target object has been fully initialized (that is, all its constructors have run)? My attribute is not applied directly to the target class but to one or more of its properties.
For the googlers (like me) who run into this issue
the OnInstanceConstructed Advice solves this problem out of the box http://doc.postsharp.net/t_postsharp_aspects_advices_oninstanceconstructedadvice