This documentation is archived and is not being maintained.

IMethodCallMessage Interface

Defines the method call message interface.

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

<ComVisibleAttribute(True)> _
Public Interface IMethodCallMessage _
	Inherits IMethodMessage, IMessage

The IMethodCallMessage type exposes the following members.

Public propertyArgCountGets the number of arguments passed to the method. (Inherited from IMethodMessage.)
Public propertyArgsGets an array of arguments passed to the method. (Inherited from IMethodMessage.)
Public propertyHasVarArgsGets a value indicating whether the message has variable arguments. (Inherited from IMethodMessage.)
Public propertyInArgCountGets the number of arguments in the call that are not marked as out parameters.
Public propertyInArgsGets an array of arguments that are not marked as out parameters.
Public propertyLogicalCallContextGets the LogicalCallContext for the current method call. (Inherited from IMethodMessage.)
Public propertyMethodBaseGets the MethodBase of the called method. (Inherited from IMethodMessage.)
Public propertyMethodNameGets the name of the invoked method. (Inherited from IMethodMessage.)
Public propertyMethodSignatureGets an object containing the method signature. (Inherited from IMethodMessage.)
Public propertyPropertiesGets an IDictionary that represents a collection of the message's properties. (Inherited from IMessage.)
Public propertyTypeNameGets the full Type name of the specific object that the call is destined for. (Inherited from IMethodMessage.)
Public propertyUriGets the URI of the specific object that the call is destined for. (Inherited from IMethodMessage.)

Public methodGetArgGets a specific argument as an Object. (Inherited from IMethodMessage.)
Public methodGetArgNameGets the name of the argument passed to the method. (Inherited from IMethodMessage.)
Public methodGetInArgReturns the specified argument that is not marked as an out parameter.
Public methodGetInArgNameReturns 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.

Imports System
Imports System.Collections
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Proxies
Imports System.Runtime.Remoting.Messaging
Imports System.Security.Permissions

Namespace IMethodCallMessageNS

   ' MyProxy extends the CLR Remoting RealProxy.
   ' In the same class, in the Invoke method, we demonstrate the
   ' methods and properties of the IMethodCallMessage.

   <PermissionSet(SecurityAction.Demand, Name:="FullTrust")> _
   Public Class MyProxy
      Inherits RealProxy

      Public Sub New(ByVal myType As Type)
         ' This constructor forwards the call to base RealProxy.
         ' RealProxy uses the Type to generate a transparent proxy.
      End Sub 'New

      Public Overrides Function Invoke(ByVal myIMessage As IMessage) As IMessage
         Console.WriteLine("MyProxy.Invoke Start")

         If TypeOf myIMessage Is IMethodCallMessage Then
            Console.WriteLine("Message is of type 'IMethodCallMessage'.")

            Dim myIMethodCallMessage As IMethodCallMessage
            myIMethodCallMessage = CType(myIMessage, IMethodCallMessage)

            Console.WriteLine("InArgCount is : " + myIMethodCallMessage.InArgCount.ToString)
            Dim myObj As Object
            For Each myObj In myIMethodCallMessage.InArgs
               Console.WriteLine("InArgs is : " + myObj.ToString())

            Dim i As Integer
            For i = 0 To myIMethodCallMessage.InArgCount - 1
               Console.WriteLine("GetArgName(" + i.ToString() + ") is : " + myIMethodCallMessage.GetArgName(i))
               Console.WriteLine("GetInArg(" + i.ToString() + ") is : " + myIMethodCallMessage.GetInArg(i).ToString)
            Next i

         ElseIf TypeOf myIMessage Is IMethodReturnMessage Then
            Console.WriteLine("Message is of type 'IMethodReturnMessage'.")
         End If

         ' Build Return Message
         Dim myReturnMessage As New ReturnMessage(5, Nothing, 0, Nothing, _
                                    CType(myIMessage, IMethodCallMessage))

         Console.WriteLine("MyProxy.Invoke - Finish")
         Return myReturnMessage

      End Function 'Invoke

   End Class 'MyProxy

   ' The class used to obtain Metadata.
   <PermissionSet(SecurityAction.Demand, Name:="FullTrust")> _
   Public Class MyMarshalByRefClass
      Inherits MarshalByRefObject

      Public Function MyMethod(ByVal str As String, ByVal dbl As Double, ByVal i As Integer) As Integer
         Console.WriteLine("MyMarshalByRefClass.MyMethod {0} {1} {2}", str, dbl, i)
         Return 0
      End Function 'MyMethod
   End Class 'MyMarshalByRefClass

   ' Main class that drives the whole sample.
   Public Class ProxySample

      <SecurityPermission(SecurityAction.LinkDemand)> _
      Shared Sub Main()
         Console.WriteLine("Generate a new MyProxy.")
         Dim myProxy As New MyProxy(GetType(MyMarshalByRefClass))

         Console.WriteLine("Obtain the transparent proxy from myProxy.")
         Dim myMarshalByRefClassObj As MyMarshalByRefClass = _
                        CType(myProxy.GetTransparentProxy(), MyMarshalByRefClass)

         Console.WriteLine("Calling the Proxy.")
         Dim myReturnValue As Object = myMarshalByRefClassObj.MyMethod("Microsoft", 1.2, 6)

         Console.WriteLine("Sample Done.")
      End Sub 'Main
   End Class 'ProxySample
End Namespace 'IMethodCallMessageNS

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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.