This documentation is archived and is not being maintained.
IMethodMessage Interface
Visual Studio 2010
Defines the method message interface.
Assembly: mscorlib (in mscorlib.dll)
The IMethodMessage type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | 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. |
| Name | Description | |
|---|---|---|
![]() | GetArg | Gets a specific argument as an Object. |
![]() | GetArgName | Gets the name of the argument passed to the method. |
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.
// This class requires full trust [PermissionSetAttribute(SecurityAction::Demand, Name = "FullTrust")] public ref class MyProxyClass: public RealProxy { private: Object^ myObjectInstance; Type^ myType; public: MyProxyClass( Type^ argType ) : RealProxy( argType ) { myType = argType; myObjectInstance = Activator::CreateInstance( argType ); } // Overriding the Invoke method of RealProxy. virtual IMessage^ Invoke( IMessage^ message ) override { IMethodMessage^ myMethodMessage = dynamic_cast<IMethodMessage^>(message); Console::WriteLine( "**** Begin Invoke ****" ); Console::WriteLine( "\tType is : {0}", myType ); Console::WriteLine( "\tMethod name : {0}", myMethodMessage->MethodName ); for ( int i = 0; i < myMethodMessage->ArgCount; i++ ) { Console::WriteLine( "\tArgName is : {0}", myMethodMessage->GetArgName( i ) ); Console::WriteLine( "\tArgValue is: {0}", 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, nullptr, myObjectInstance, myMethodMessage->Args ); Console::WriteLine( "**** End Invoke ****" ); // Build the return message to pass back to the transparent proxy. ReturnMessage^ myReturnMessage = gcnew ReturnMessage( returnValue,nullptr,0,nullptr,dynamic_cast<IMethodCallMessage^>(message) ); return myReturnMessage; } };
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show:
