What is the best implementation for AOP in .Net? [closed]

There is a lot of AOP implementation in C#, VB.net. this is some of AOP Implementations:

What is the best implementation for AOP in .Net? What I should use?

What are the best/most popular ways to do aspect-oriented programming (AOP) in C#/.Net?

What are the best/most popular ways to do aspect-oriented programming (AOP) in C#/.Net?

AOP implementation

What is the best way to have your own home-grown Java-based implementation of Aspect-Oriented-Programming? P.S.: The possible argument would be to use Spring AOP, but I have a project that is not Spri

Castle AOP Implementation in .NET

I have been looking at a couple of AOP frameworks to use one in a forthcoming project. The two I have been looking at our Spring.NET and Castle. I am struggling to find any sample projects that make u

Is SPRING.Net the best framework for Aspect Oriented Programming(AOP)? [closed]

Please give me the advantages and disadvantages of using the particular framework. Can give me examples of successes where you have used AOP in you .net applications?

What are best practices for AOP development?

I’m looking for best practices guidelines for developers seeking to learn AOP. Anything from actual coding techniques to IDE suggestions would be a big help here. UPDATE: In particular, I’m interested

Best StAX Implementation [closed]

My quick search reveals the reference implementation (http://stax.codehaus.org), the Woodstox implementation (http://woodstox.codehaus.org), and Sun’s SJSXP implementation (https://sjsxp.dev.java.net/

Best ASP.NET Background Service Implementation

What’s the best implementation for more than one background service in an ASP.NET application? Timer Callback Timer timer = new Timer(new TimerCallback(MyWorkCallback), HttpContext, 5000, 5000); Thr

.NET Code refactorings, what is your best practice? [closed]

What are your .NET code-refactoring best practices?

Best Utility Class Implementation [closed]

I have read several questions regarding when to use a utility class or any class that doesn’t have a state associated with it. My question is what is the best implementation once you have decided to

AOP programming in .Net?

I’m wondering what’s good out there for AOP / crosscutting in .Net, along the lines of AspectJ. I see Microsoft has a Policy Injection Application Block; any other good stuff out there I should take a


“Best” is subjective.

First, draw up a list of the features you need, your architecture, etc. Then look for options that do what you need, without introducing unnecessary complexity. For example, several are interface oriented: is your code currently interface oriented? If not, PostSharp might be a better choice (being weaved into the original classes). But of course, PostSharp can’t be configured at runtime… horses for courses.

I don’t know about best, there are a lot of frameworks and not enough hours in the day to try them all.

I did use PostSharp and was pleasantly surprised how easy it is to get started with it.

I also looked into AOP with Castle Windsor and Spring.Net, the approach is different (runtime vs compile time). Mixing AOP and IoC seems to make sense. When you’re not using one of these frameworks yet it’s a lot more work to get started but don’t let that stop you.

For new projects now I’d probably use Castle Windsor, but that’s mostly because I’d also want to use IoC. If i had to quickly implement AOP into an existing code base I’d use PostSharp.

I think that Castle Dynamic Proxy is the solution of choice if dynamic interception can handle your needs. This framework is used internally by a lot of other frameworks that want to offer AOP capabilities. Typically, most of existing IoC containers now provide some dynamic interception mechanisms (Spring.NET, Castle Windsor, StructureMap, etc.) If you already work with an IoC container, maybe it could be easier to look at what it proposes.

If dynamic interception can’t address your needs (weaving sealed class, intercepting non-virtual call, etc.), then you certainly want static weaving. PostSharp is the reference in this domain.

Note that it also exists Linfu, that can be used to leverage both AOP fashions.

There’s also Policy Injection and Unity Interception from Microsoft.

The best way to do aspect-oriented programming in .NET is to start with using proper design techniques. For instance, by applying the SOLID principles you can achieve the flexibility and modularity you need to allow adding cross-cutting concerns. If you have the design right, you will even be able to apply most cross-cutting concerns without any framework.

Here are some pointers:

  • Don’t depend on concrete instances, but depend on abstractions.
  • Don’t mix cross-cutting concerns and business logic in the same class.
  • Adding cross-cutting concerns by wrapping classes with business logic in classes that implement those concerns (decorators).

When you’ve got the right abstractions in place, adding new cross-cutting concerns to the system is just a matter of writing a new decorator class and wrapping it around the right implementations.

Although techniques such as interception and code weaving could make it easier to work with a badly designed application, there is truly no alternative for good design. Sooner or later you will get burned. This doesn’t mean that interception and code weaving should not be used though. But without a proper application design even those techniques will just be marginally helpful.