<p>I've been using some basic AOP style solutions for cross-cutting concerns like security, logging, validation, etc.  My solution has revolved around <a href="http://www.castleproject.org/container/index.html" rel="nofollow noreferrer">Castle Windsor</a> and DynamicProxy because I can apply everything using a Boo based DSL and keep my code clean of Attributes. I was told at the weekend to have a look at <a href="http://www.postsharp.org/" rel="nofollow noreferrer">PostSharp</a> as it's supposed to be a "better" solution.  I've had a quick look at PostSharp, but I've been put off by the Attribute usage.</p>

<p>Has anyone tried both solutions and would care to share their experiences?</p>

[{'answer_id': 62911, 'author': 'Mendelt', 'author_id': 3320, 'author_profile': 'https://Stackoverflow.com/users/3320', 'pm_score': 4, 'selected': True, 'text': "<p>I only looked at castle-windsor for a short time (yet) so I can't comment on that but I did use postsharp.</p>\n\n<p>Postsharp works by weaving at compile time. It ads a post-compile step to your build where it modifies your code. The code is compiled as if you just programmed the cross cutting concerns into you code. This is a bit more performant than runtime weaving and because of the use of attributes Postsharp is very easy to use. I think using attributes for AOP isn't as problematic as using it for DI. But that's just my personal taste.</p>\n\n<p>But...</p>\n\n<p>If you already use castle for dependency injection I don't see a good reason why you shouldn't also use it for AOP stuff. I think though the AOP at runtime is a bit slower than at compile time it's also more powerful. AOP and DI are in my opinion related concepts so I think it's a good idea to use one framework for both. So I'll probably look at the castle stuff again next project I need AOP.</p>\n"}, {'answer_id': 94083, 'author': 'Stacy A', 'author_id': 17824, 'author_profile': 'https://Stackoverflow.com/users/17824', 'pm_score': 4, 'selected': False, 'text': "<p>Couple of minor issues with PostSharp...</p>\n\n<p>One issue I've had with PostSharp is that whilst using asp.net, line numbers for exception messages are 'out' by the number of IL instructions injected into asssemblies by PostSharp as the PDBs aren't injected as well :-).</p>\n\n<p>Also, without the PostSharp assemblies available at runtime, runtime errors occur.  Using Windsor, the cross-cuts can be turned off at a later date without a recompile of code.</p>\n\n<p>(hope this makes sense)</p>\n"}]
['https://Stackoverflow.com/questions/62798', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5802/']