I have tried to use PostSharp v2 to implement some aspect oriented programming inside a SharePoint application: pretty basic stuff, like logging aspects for unhandled exceptions and such.
I noticed that PostSharp seems to have some problem at compile time if the processed assembly exists in the GAC. The build process would just fail - that means that if you need to recompile a project that uses aspects you will need to retract the solution from SharePoint, compile and then redeploy it.
I also have some random problems when using aspects inside a custom WCF service hosted on SharePoint. Including an aspect in the same dll of the service implementation seems to randomly break some of my custom services - accessing the mex endpoint just return a 401 error (not found). Notice that this seems to happen even if the service does not actually use the aspects - it is like if the sole presence of an aspect class in the code can "break" the whole assembly.
I am left wondering if I am doing something wrong or there are some known issue when using PostSharp with SharePoint. I would like to know if anybody has successfully used Postsharp on a SharePoint 2010 project. I am also open to suggestion of tested alternatives that would allow for AOP use.
NOTE: I am using PostSharp 2. I know that there is a v3 available. Do anyone know if it makes any difference?