I have a probleme with Postsharp.
i have this:
[Serializable]
public class MethodConnectionTracking: OnExceptionAspect
{
public override void OnException(MethodExecutionArgs args)
{
base.OnException(args);
}
}
and i used like this. In assemblyInfo.cs:
[assembly: MethodConnectionTracking]
so, when an exception occurs in the assembly its executes OnException method. But, when i debug the method and i watch args (type: MethodExecutionArgs ) every property has a null value. args.Exception is null. And i need the exception type..
Anyone knows how can i fix this?
Thanks in advance
The answer if because PostSharp sees that you are not using any of those properties so it implements optimizations to not do anything with those properties. that is why they are null when you debug. change your aspect to match the following ocde then try to debug again
[Serializable]
public class MethodConnectionTracking: OnExceptionAspect
{
public override void OnException(MethodExecutionArgs args)
{
Exception e = args.Exception;
}
}
you can see exactly why here: http://programmersunlimited.wordpress.com/2011/08/01/postsharp-why-are-my-arguments-null/
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