IMethodMessage Interface
.NET Framework 3.0
Defines the method message interface.
Namespace: System.Runtime.Remoting.Messaging
Assembly: mscorlib (in mscorlib.dll)
Assembly: mscorlib (in mscorlib.dll)
The following example code shows a custom proxy that overrides RealProxy.Invoke in order to write the message information to the console and return immediately without making a remote call.
[PermissionSet(SecurityAction.Demand, Name="FullTrust")] public class MyProxyClass : RealProxy { private Object myObjectInstance = null; private Type myType = null; public MyProxyClass(Type argType) : base(argType) { myType = argType; myObjectInstance = Activator.CreateInstance(argType); } // Overriding the Invoke method of RealProxy. public override IMessage Invoke(IMessage message) { IMethodMessage myMethodMessage = (IMethodMessage)message; Console.WriteLine("**** Begin Invoke ****"); Console.WriteLine("\tType is : " + myType); Console.WriteLine("\tMethod name : " + myMethodMessage.MethodName); for (int i=0; i < myMethodMessage.ArgCount; i++) { Console.WriteLine("\tArgName is : " + myMethodMessage.GetArgName(i)); Console.WriteLine("\tArgValue is: " + myMethodMessage.GetArg(i)); } if(myMethodMessage.HasVarArgs) Console.WriteLine("\t The method have variable arguments!!"); else Console.WriteLine("\t The method does not have variable arguments!!"); // Dispatch the method call to the real object. Object returnValue = myType.InvokeMember( myMethodMessage.MethodName, BindingFlags.InvokeMethod, null, myObjectInstance, myMethodMessage.Args ); Console.WriteLine("**** End Invoke ****"); // Build the return message to pass back to the transparent proxy. ReturnMessage myReturnMessage = new ReturnMessage( returnValue, null, 0, null, (IMethodCallMessage)message ); return myReturnMessage; } }
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: