IMethodCallMessage Interface

Defines the method call message interface.

Namespace: System.Runtime.Remoting.Messaging
Assembly: mscorlib (in mscorlib.dll)

public interface IMethodCallMessage : IMethodMessage, IMessage
/** @attribute ComVisibleAttribute(true) */ 
public interface IMethodCallMessage extends IMethodMessage, IMessage
public interface IMethodCallMessage extends IMethodMessage, IMessage
Not applicable.

An IMethodCallMessage is generated as a result of a method called on a remote object, and is used to transport details about the remote method call to the server side.

using System;
using System.Collections;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Proxies;
using System.Runtime.Remoting.Messaging;
using System.Security.Permissions;

namespace IMethodCallMessageNS
   // MyProxy extends the CLR Remoting RealProxy.
   // In the same class, in the Invoke method, the methods and properties of the 
   // IMethodCallMessage are demonstrated.

   [PermissionSet(SecurityAction.Demand, Name="FullTrust")]
   public class MyProxy : RealProxy
      public MyProxy(Type myType) : base(myType)
         // This constructor forwards the call to base RealProxy.
         // RealProxy uses the Type to generate a transparent proxy.

      public override IMessage Invoke(IMessage myIMessage)
         Console.WriteLine("MyProxy.Invoke Start");
         ReturnMessage myReturnMessage = null;
         if (myIMessage is IMethodCallMessage)
            Console.WriteLine("Message is of type 'IMethodCallMessage'.");

            IMethodCallMessage myIMethodCallMessage;
            Console.WriteLine("InArgCount is  : " + 
            foreach (object myObj in myIMethodCallMessage.InArgs)
               Console.WriteLine("InArgs is : " + myObj.ToString());

            for(int i=0; i<myIMethodCallMessage.InArgCount; i++)
               Console.WriteLine("GetArgName(" +i.ToString() +") is : " + 
               Console.WriteLine("GetInArg("+i.ToString() +") is : " +
         else if (myIMessage is IMethodReturnMessage)
            Console.WriteLine("Message is of type 'IMethodReturnMessage'.");
         // Build Return Message
         myReturnMessage = new ReturnMessage(5,null,0,null,
         Console.WriteLine("MyProxy.Invoke - Finish");
         return myReturnMessage;

   // The class used to obtain Metadata.
   [PermissionSet(SecurityAction.Demand, Name="FullTrust")]
   public class MyMarshalByRefClass : MarshalByRefObject
      public int MyMethod(string str, double dbl, int i)
         Console.WriteLine("MyMarshalByRefClass.MyMethod {0} {1} {2}", str, dbl, i);
         return 0;
   // Main class that drives the whole sample.
   public class ProxySample
      public static void Main()
         Console.WriteLine("Generate a new MyProxy.");
         MyProxy myProxy = new MyProxy(typeof(MyMarshalByRefClass));

         Console.WriteLine("Obtain the transparent proxy from myProxy.");
         MyMarshalByRefClass myMarshalByRefClassObj = 

         Console.WriteLine("Calling the Proxy.");
         object myReturnValue = myMarshalByRefClassObj.MyMethod("Microsoft", 1.2, 6);
         Console.WriteLine("Sample Done.");

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.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0