I am coming to AOP and it seems .NET PostSharp is the way to go.
I want to make some simple db entries when an exception occurs. However, itβs hard for me to find any real compelling examples of using PostSharp beyond the basics. I tried the following:
[Serializable] public sealed class LogExceptionAttribute : ExceptionHandlerAspect { public override void OnException(MethodExecutionEventArgs eventArgs) {
And then binding the [LogException] attribute to the method
But I get a compilation error:
Error 7 The type "CoDrivrBeta1.Classes.LogExceptionAttribute" or one of its ancestor should be decorated by an instance of MulticastAttributeUsageAttribute. C:\work\CoDrivrBeta1\CoDrivrBeta1\EXEC CoDrivrBeta1
I have to admit that I am very new to this, but it seems like an interesting concept, I think I just need to point in the right direction
source share