I'm attempting to use ContextBoundObject, ContextAttribute, and IContextProperty to build a simple interception capability (very much like Juval Lowy's excellent article in the March '03 MSDN Magazine). I'm implementing IContributeServerContextSink and a generic implementation of IMessageSink to get the basics working.
[MyContextAttribute] public class MyClass : ContextBoundObject { ... } Everything works so long as my application declares and creates my context- bound class directly in the code. My IMessageSink object gets SyncProcessMessage calls twice (once for the constructor, once for DoSomething): Main() { MyClass myClass = new myClass(); // Gets intercepted myClass.DoSomething(); // Gets intercepted } However, if I create an instance of my class from a class created by ASP.NET, my IMessageSink implementation never gets called: [WebMethod] public string Hello() { MyClass myClass = new myClass(); // No interception! myClass.DoSomething(); // No interception! return "Hello World"; } In a likely related issue, if I create an instance of my context-bound class using the Activator and Invoke DoSomething via reflection, I also get no interception: Assembly asm = Assembly.LoadFrom(@"c:\temp\MyAssembly.dll"); System.Type theType = asm.GetType("Namespace.MyClass"); object obj = Activator.CreateInstance(theType); // No interception! MethodInfo method = theType.GetMethod("DoSomething"); object rtn = method.Invoke(obj, new object[]); // No interception! I suspect since ASP.NET is effectively doing the same thing one solution probably solves both problems. Thanks in advance for any advice, Erik Johnson Epicor Software Corporation