Assumed I have an aspect implementing IInstanceScopedAspect
and I have this aspect applied to methods in a type. How can I initialize the aspects when creating the object with FormatterServices.GetUninitializedObject
? The constructor is not executed and therefore I get a NullReferenceException
when I execute the method where the aspect is applied.
Is there a PostSharp API which can be used to initialize the object's aspects ?
There is a InitializeCurrentAspects
method available for exactly this scenario, as documented here; http://doc.sharpcrafters.com/postsharp-2.0/Default.aspx##PostSharp-2.0.chm/html/M_PostSharp_Aspects_AspectUtilities_InitializeCurrentAspects.htm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With