Erik, I tried to reproduce your secoind test case, i.e. make late-bound calls to a context-bound object through reflection, and I can't reproduce the behaviour you described.
Using some AOP-like services I implemented myself a little while ago, I defined a textbook 'tracable' class. I put this class in a library assembly. Then I wrote a simple console app that loads the assembly through Assembly.LoadFrom, gets the type of the class through Assembly.GetType, and gets a MethodInfo object for a (traced) method through Type.GetMethod. The app creates an instance of the class through Activator.CreateInstance and it calls the method through MethodInfo.Invoke. As expected, the call to the method is neatly traced, implying that the method-call and method-return messages are intercepted. Can you perhaps provide us with some more info on your particular implementation---maybe attach some source code? Regards, Stefan >-----Original Message----- >From: [EMAIL PROTECTED] >[mailto:[EMAIL PROTECTED] On Behalf >Of Erik Johnson >Sent: Thursday, February 27, 2003 3:25 AM >To: [EMAIL PROTECTED] >Cc: Erik Johnson >Subject: Remoting: Custom Message Sink > > >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 >