IMethodMessage Interface

Definition

Defines the method message interface.

public interface IMethodMessage : System.Runtime.Remoting.Messaging.IMessage
[System.Runtime.InteropServices.ComVisible(true)]
public interface IMethodMessage : System.Runtime.Remoting.Messaging.IMessage
Derived
Attributes
Implements

Examples

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.

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;
   }
}

Remarks

A method message is used to send information to and from remote methods. For example, messages used for remote method calls implement the IMethodMessage interface.

Properties

ArgCount

Gets the number of arguments passed to the method.

Args

Gets an array of arguments passed to the method.

HasVarArgs

Gets a value indicating whether the message has variable arguments.

LogicalCallContext

Gets the LogicalCallContext for the current method call.

MethodBase

Gets the MethodBase of the called method.

MethodName

Gets the name of the invoked method.

MethodSignature

Gets an object containing the method signature.

Properties

Gets an IDictionary that represents a collection of the message's properties.

(Inherited from IMessage)
TypeName

Gets the full Type name of the specific object that the call is destined for.

Uri

Gets the URI of the specific object that the call is destined for.

Methods

GetArg(Int32)

Gets a specific argument as an Object.

GetArgName(Int32)

Gets the name of the argument passed to the method.

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1