Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IMethodCallMessage Interface

 

Defines the method call message interface.

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

[ComVisibleAttribute(true)]
public interface class IMethodCallMessage : IMethodMessage, IMessage

NameDescription
System_CAPS_pubpropertyArgCount

Gets the number of arguments passed to the method.(Inherited from IMethodMessage.)

System_CAPS_pubpropertyArgs

Gets an array of arguments passed to the method.(Inherited from IMethodMessage.)

System_CAPS_pubpropertyHasVarArgs

Gets a value indicating whether the message has variable arguments.(Inherited from IMethodMessage.)

System_CAPS_pubpropertyInArgCount

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

System_CAPS_pubpropertyInArgs

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

System_CAPS_pubpropertyLogicalCallContext

Gets the LogicalCallContext for the current method call.(Inherited from IMethodMessage.)

System_CAPS_pubpropertyMethodBase

Gets the MethodBase of the called method.(Inherited from IMethodMessage.)

System_CAPS_pubpropertyMethodName

Gets the name of the invoked method.(Inherited from IMethodMessage.)

System_CAPS_pubpropertyMethodSignature

Gets an object containing the method signature.(Inherited from IMethodMessage.)

System_CAPS_pubpropertyProperties

Gets an IDictionary that represents a collection of the message's properties.(Inherited from IMessage.)

System_CAPS_pubpropertyTypeName

Gets the full Type name of the specific object that the call is destined for.(Inherited from IMethodMessage.)

System_CAPS_pubpropertyUri

Gets the URI of the specific object that the call is destined for.(Inherited from IMethodMessage.)

NameDescription
System_CAPS_pubmethodGetArg(Int32)

Gets a specific argument as an Object.(Inherited from IMethodMessage.)

System_CAPS_pubmethodGetArgName(Int32)

Gets the name of the argument passed to the method.(Inherited from IMethodMessage.)

System_CAPS_pubmethodGetInArg(Int32)

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

System_CAPS_pubmethodGetInArgName(Int32)

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

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 namespace System;
using namespace System::Collections;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Proxies;
using namespace System::Runtime::Remoting::Messaging;

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

[System::Security::Permissions::SecurityPermissionAttribute
(System::Security::Permissions::SecurityAction::LinkDemand, 
Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)]
[System::Security::Permissions::SecurityPermissionAttribute
(System::Security::Permissions::SecurityAction::InheritanceDemand, 
Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)]

public ref class MyProxy: public RealProxy
{
public:
   MyProxy( Type^ myType )
      : RealProxy( myType )
   {
      // This constructor forwards the call to base RealProxy.
      // RealProxy uses the Type to generate a transparent proxy.
   }

   virtual IMessage^ Invoke( IMessage^ myIMessage ) override
   {
      Console::WriteLine( "MyProxy::Invoke Start" );
      Console::WriteLine( "" );
      ReturnMessage^ myReturnMessage = nullptr;
      if ( dynamic_cast<IMethodCallMessage^>(myIMessage) )
      {
         Console::WriteLine( "Message is of type 'IMethodCallMessage*'." );
         Console::WriteLine( "" );
         IMethodCallMessage^ myIMethodCallMessage;
         myIMethodCallMessage = dynamic_cast<IMethodCallMessage^>(myIMessage);
         Console::WriteLine( "InArgCount is  : {0}", myIMethodCallMessage->InArgCount );
         IEnumerator^ myEnum = myIMethodCallMessage->InArgs->GetEnumerator();
         while ( myEnum->MoveNext() )
         {
            Object^ myObj = safe_cast<Object^>(myEnum->Current);
            Console::WriteLine( "InArgs is : {0}", myObj );
         }

         for ( int i = 0; i < myIMethodCallMessage->InArgCount; i++ )
         {
            Console::WriteLine( "GetArgName({0}) is : {1}", i, myIMethodCallMessage->GetArgName( i ) );
            Console::WriteLine( "GetInArg({0}) is : {0}", i, myIMethodCallMessage->GetInArg( i ) );

         }
         Console::WriteLine( "" );
      }
      else
      if ( dynamic_cast<IMethodReturnMessage^>(myIMessage) )
            Console::WriteLine( "Message is of type 'IMethodReturnMessage*'." );

      // Build Return Message 
      myReturnMessage = gcnew ReturnMessage( 5,nullptr,0,nullptr,dynamic_cast<IMethodCallMessage^>(myIMessage) );
      Console::WriteLine( "MyProxy::Invoke - Finish" );
      return myReturnMessage;
   }
};

// The class used to obtain Metadata.
public ref class MyMarshalByRefClass: public MarshalByRefObject
{
public:
   int MyMethod( String^ str, double dbl, int i )
   {
      Console::WriteLine( "MyMarshalByRefClass::MyMethod {0} {1} {2}", str, dbl, i );
      return 0;
   }

};

// Main routine that drives the whole sample.
int main()
{
   Console::WriteLine( "Generate a new MyProxy." );
   MyProxy^ myProxy = gcnew MyProxy( MyMarshalByRefClass::typeid );
   Console::WriteLine( "Obtain the transparent proxy from myProxy." );
   MyMarshalByRefClass^ myMarshalByRefClassObj = dynamic_cast<MyMarshalByRefClass^>(myProxy->GetTransparentProxy());
   Console::WriteLine( "Calling the Proxy." );
   Object^ myReturnValue = myMarshalByRefClassObj->MyMethod( "Microsoft", 1.2, 6 );
   Console::WriteLine( "Sample Done." );
   return 0;
}

.NET Framework
Available since 1.1
Return to top
Show: