IMethodMessageとは? わかりやすく解説

IMethodMessage インターフェイス

メソッド メッセージインターフェイス定義します

名前空間: System.Runtime.Remoting.Messaging
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<ComVisibleAttribute(True)> _
Public Interface IMethodMessage
    Inherits IMessage
Dim instance As IMethodMessage
[ComVisibleAttribute(true)] 
public interface IMethodMessage : IMessage
[ComVisibleAttribute(true)] 
public interface class IMethodMessage : IMessage
/** @attribute ComVisibleAttribute(true) */ 
public interface IMethodMessage extends IMessage
ComVisibleAttribute(true) 
public interface IMethodMessage extends IMessage
解説解説
使用例使用例

RealProxy.Invokeオーバーライドして、メッセージ情報コンソール書き込むカスタム プロキシについては、次のコード例参照してください。この例では、リモート呼び出し実行せずすぐに制御戻します

<PermissionSet(SecurityAction.Demand, Name:="FullTrust")>
 _
Public Class MyProxyClass
   Inherits RealProxy
   Private myObjectInstance As Object
 = Nothing
   Private myType As Type = Nothing
   
   Public Sub New(argType
 As Type)
      MyBase.New(argType)
      myType = argType
      myObjectInstance = Activator.CreateInstance(argType)
   End Sub 'New
   
   ' Overriding the Invoke method of RealProxy.
   Public Overrides Function
 Invoke(message As IMessage) As IMessage
      Dim myMethodMessage As IMethodMessage
 = CType(message, IMethodMessage)
      
      Console.WriteLine("**** Begin Invoke ****")
      Console.WriteLine(ControlChars.Tab + "Type is : "
 + myType.ToString())
      Console.WriteLine(ControlChars.Tab + "Method name : "
 + myMethodMessage.MethodName)
      
      Dim i As Integer
      For i = 0 To myMethodMessage.ArgCount
 - 1
         Console.WriteLine(ControlChars.Tab + "ArgName is : "
 + myMethodMessage.GetArgName(i))
         Console.WriteLine(ControlChars.Tab + "ArgValue is: "
 + myMethodMessage.GetArg(i))
      Next i
      
      If myMethodMessage.HasVarArgs Then
         Console.WriteLine(ControlChars.Tab + " The method have
 variable arguments!!")
      Else
         Console.WriteLine(ControlChars.Tab + " The method does
 not have variable arguments!!")
      End If 
      ' Dispatch the method call to the real object.
      Dim returnValue As Object
 = myType.InvokeMember(myMethodMessage.MethodName, _
                     BindingFlags.InvokeMethod, Nothing, myObjectInstance,
 myMethodMessage.Args)
      Console.WriteLine("**** End Invoke ****")
      
      ' Build the return message to pass back to the transparent proxy.
      Dim myReturnMessage As New
 ReturnMessage(returnValue, Nothing, 0, Nothing,
 _
                                                         CType(message, IMethodCallMessage))
      Return myReturnMessage
   End Function 'Invoke
End Class 'MyProxyClass
[PermissionSet(SecurityAction.Demand, Name="FullTrust")]
public class MyProxyClass : RealProxy
{
   private Object  myObjectInstance  = null;
   private Type    myType      = null;

   public MyProxyClass(Type argType) : base(argType)
   {
      myType = argType;
      myObjectInstance = Activator.CreateInstance(argType);
   }

   // Overriding the Invoke method of RealProxy.
   public override IMessage Invoke(IMessage message)
   {
      IMethodMessage myMethodMessage = (IMethodMessage)message;

      Console.WriteLine("**** Begin Invoke ****");
      Console.WriteLine("\tType is : " + myType);
      Console.WriteLine("\tMethod name : " +  myMethodMessage.MethodName);

      for (int i=0; i < myMethodMessage.ArgCount;
 i++)
      {
         Console.WriteLine("\tArgName is : " + myMethodMessage.GetArgName(i));
         Console.WriteLine("\tArgValue is: " + 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,
 null,
                                           myObjectInstance, myMethodMessage.Args
 );
      Console.WriteLine("**** End Invoke ****");

      // Build the return message to pass back to the transparent proxy.
      ReturnMessage myReturnMessage = new ReturnMessage( returnValue,
 null, 0, null,
          (IMethodCallMessage)message );
      return myReturnMessage;
   }
}
// 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;
   }
};
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
IMethodMessage メンバ
System.Runtime.Remoting.Messaging 名前空間

IMethodMessage プロパティ


パブリック プロパティパブリック プロパティ

参照参照

関連項目

IMethodMessage インターフェイス
System.Runtime.Remoting.Messaging 名前空間

IMethodMessage メソッド


パブリック メソッドパブリック メソッド

  名前 説明
パブリック メソッド GetArg 指定した引数Object 型として取得します
パブリック メソッド GetArgName メソッド渡され引数の名前を取得します
参照参照

関連項目

IMethodMessage インターフェイス
System.Runtime.Remoting.Messaging 名前空間

IMethodMessage メンバ




英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「IMethodMessage」の関連用語

IMethodMessageのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



IMethodMessageのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS