AOP and .NET: Are contexts a deprecated concept?
I recently started learning about contexts in .NET (context sensitive, context sensitive, message sinks, etc.). Several signal bells began to ring:
- All context-related classes are derived from ContextBoundObject, which in turn receives from MarshalByRefObject. MarshalByRefObject is part of the .NET Remoting architecture. .NET Remoting architecture is deprecated.
- Most .NET books pay little attention to the concept of contexts.
- MSDN barely provides any information about Contexts: the classes are explained, but no articles with the site (eg How, Overview, Tutorials, etc.) are provided.
- Most discussion articles and forums discuss Contexts - several years.
- Aside from the synchronization context, it seems that the .NET framework uses very little of the Contexts architecture.
So my question is, is the concept of contexts in .NET obsolete and what should be avoided in newer designs? If this is deprecated, what alternatives are recommended?
source to share
Yes, avoid MarshalByRefObject and ContextBoundObject for AOP.
I rolled a custom AOP solution about four years ago using the context-bound MarshalByRefObject method. I knew that at the time I was walking the rabbit hole, but I did it anyway, because many of the AOP systems for .NET were still very young.
The fact that .NET supports AOP with MarshalByRefObject is a fluke. MBO was never intended for this purpose, and using MBO for AOP is to capture the original intent of .NET and MBO remote working.
None of this means that .NET cannot support AOP, it just needs to be done in a less "hacky" way, using an AOP-enabled framework like Spring.NET, PostSharp, and others.
Here is a good, if slightly outdated, article on AOP frameworks for .NET.
source to share