I am adventuring into some AOP and it seems with .NET PostSharp is the way to go.
I want to do some simple logging to the db when an exception occurs. However I am finding it difficult to find any real solid examples of using PostSharp beyond the basics. I tried the following:
[Serializable]
public sealed class LogExceptionAttribute : ExceptionHandlerAspect
{
public override void OnException(MethodExecutionEventArgs eventArgs)
{
//do some logging here
}
}
And then attaching a [LogException]
attribute to a method
But I get a compile 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 confess I am very new to this, but it seems like an interesting concept, I think i just need to be pointed in the right direction