IMethodCallMessage Interface

Definition

Defines the method call message interface.

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

Examples

C#
using System;
using System.Collections;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Proxies;
using System.Runtime.Remoting.Messaging;

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.

   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");
         Console.WriteLine("");
         ReturnMessage myReturnMessage = null;

         if (myIMessage is IMethodCallMessage)
         {
            Console.WriteLine("Message is of type 'IMethodCallMessage'.");
            Console.WriteLine("");

            IMethodCallMessage myIMethodCallMessage;
            myIMethodCallMessage=(IMethodCallMessage)myIMessage;
            Console.WriteLine("InArgCount is  : " +
                              myIMethodCallMessage.InArgCount.ToString());

            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 : " +
                                       myIMethodCallMessage.GetArgName(i));
               Console.WriteLine("GetInArg("+i.ToString() +") is : " +
                              myIMethodCallMessage.GetInArg(i).ToString());
            }
            Console.WriteLine("");
         }
         else if (myIMessage is IMethodReturnMessage)
            {
                Console.WriteLine("Message is of type 'IMethodReturnMessage'.");
            }

            // Build Return Message
            myReturnMessage = new ReturnMessage(5,null,0,null,
                                       (IMethodCallMessage)myIMessage);

         Console.WriteLine("MyProxy.Invoke - Finish");
         return myReturnMessage;
      }
   }

   // The class used to obtain Metadata.
   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 =
                              (MyMarshalByRefClass)myProxy.GetTransparentProxy();

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

         Console.WriteLine("Sample Done.");
      }
   }
}

Remarks

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.

Properties

ArgCount

Gets the number of arguments passed to the method.

(Inherited from IMethodMessage)
Args

Gets an array of arguments passed to the method.

(Inherited from IMethodMessage)
HasVarArgs

Gets a value indicating whether the message has variable arguments.

(Inherited from IMethodMessage)
InArgCount

Gets the number of arguments in the call that are not marked as out parameters.

InArgs

Gets an array of arguments that are not marked as out parameters.

LogicalCallContext

Gets the LogicalCallContext for the current method call.

(Inherited from IMethodMessage)
MethodBase

Gets the MethodBase of the called method.

(Inherited from IMethodMessage)
MethodName

Gets the name of the invoked method.

(Inherited from IMethodMessage)
MethodSignature

Gets an object containing the method signature.

(Inherited from IMethodMessage)
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.

(Inherited from IMethodMessage)
Uri

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

(Inherited from IMethodMessage)

Methods

GetArg(Int32)

Gets a specific argument as an Object.

(Inherited from IMethodMessage)
GetArgName(Int32)

Gets the name of the argument passed to the method.

(Inherited from IMethodMessage)
GetInArg(Int32)

Returns the specified argument that is not marked as an out parameter.

GetInArgName(Int32)

Returns the name of the specified argument that is not marked as an out parameter.

Applies to

Proizvod Verzije
.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