IMethodReturnMessage.Exception 속성

정의

메서드를 호출하는 동안 throw된 예외를 가져옵니다.

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

속성 값

Exception

메서드 호출에 대한 예외 개체이거나, 메서드가 예외를 throw하지 않은 경우 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

적용 대상