Recently I've started learning about Contexts in .NET (context-bound, context-agile, message sinks, etc.). Several alarm bells started ringing:
Thus, my question is: Is the concept of Contexts in .NET obsolete and should be avoided in new developments? If it is obsolete, what alternatives are recommended?
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 at the time I was going down a rabbit hole but did it anyway because many of the AOP frameworks for .NET were still very young.
The fact that .NET supports AOP with MarshalByRefObject is a happy accident. MBO was never intended for that purpose, and using MBO for AOP is a hijacking of the original intent of .NET remoting and MBO.
None of this means that .NET can't support AOP, just that it should be done in a less "hacky" way, using a framework that supports AOP, like Spring.NET, PostSharp, and others.
Here is a good, if a little dated, article on AOP frameworks for .NET.