5

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 ?

Matthias
  • 15,919
  • 5
  • 39
  • 84

1 Answers1

1

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

RJ Lohan
  • 6,497
  • 3
  • 34
  • 54