IMethodReturnMessage.Exception プロパティ

定義

メソッドの呼び出し中にスローされた例外を取得します。

public:
 property Exception ^ Exception { Exception ^ get(); };
public Exception Exception { get; }
public Exception Exception { [System.Security.SecurityCritical] get; }
member this.Exception : Exception
[<get: System.Security.SecurityCritical>]
member this.Exception : Exception
Public ReadOnly Property Exception As Exception

プロパティ値

メソッド呼び出しに対してスローされた例外オブジェクト。メソッドが例外をスローしなかった場合は null

属性

例外

即時呼び出し元は、インターフェイスへの参照を使用して呼び出しを行い、インフラストラクチャのアクセス許可はありません。

次のコード例は、戻りメッセージ情報を書き込むために RealProxy.Invoke をオーバーライドするカスタム プロキシを示しています。これには、メソッドが例外をスローしたかどうかも含まれます。

virtual IMessage^ Invoke( IMessage^ myMessage ) override
{
   IMethodCallMessage^ myCallMessage = dynamic_cast<IMethodCallMessage^>(myMessage);

   IMethodReturnMessage^ myIMethodReturnMessage =
      RemotingServices::ExecuteMessage( myMarshalByRefObject, myCallMessage );
   if ( myIMethodReturnMessage->Exception != nullptr )
   {
      Console::WriteLine( "{0} raised an exception.",
         myIMethodReturnMessage->MethodName );
   }
   else
   {
      Console::WriteLine(  "{0} does not raise an exception.",
         myIMethodReturnMessage->MethodName );
   }

   return myIMethodReturnMessage;
}
public override IMessage Invoke(IMessage myMessage)
{
   IMethodCallMessage myCallMessage = (IMethodCallMessage)myMessage;

   IMethodReturnMessage myIMethodReturnMessage =
      RemotingServices.ExecuteMessage(myMarshalByRefObject,myCallMessage);
   if(myIMethodReturnMessage.Exception != null)
      Console.WriteLine(myIMethodReturnMessage.MethodName +
         " raised an exception.");
   else
      Console.WriteLine(myIMethodReturnMessage.MethodName +
         " does not raised an exception.");

   return myIMethodReturnMessage;
}
Public Overrides Function Invoke(myMessage As IMessage) As IMessage
   Dim myCallMessage As IMethodCallMessage = CType(myMessage, IMethodCallMessage)
   
   Dim myIMethodReturnMessage As IMethodReturnMessage = RemotingServices.ExecuteMessage _
                                                   (myMarshalByRefObject, myCallMessage)
   If Not (myIMethodReturnMessage.Exception Is Nothing) Then
      Console.WriteLine(myIMethodReturnMessage.MethodName + " raised an exception.")
   Else
      Console.WriteLine(myIMethodReturnMessage.MethodName + " does not raised an exception.")
   End If
   
   Return myIMethodReturnMessage
End Function 'Invoke

適用対象