IMethodReturnMessage.Exception Property

Definition

Gets the exception thrown during the method call.

C#
public Exception Exception { get; }
C#
public Exception Exception { [System.Security.SecurityCritical] get; }

Property Value

The exception object for the method call, or null if the method did not throw an exception.

Attributes

Exceptions

The immediate caller makes the call through a reference to the interface and does not have infrastructure permission.

Examples

The following example code shows a custom proxy that overrides RealProxy.Invoke in order to write the return message information, including whether the method threw an exception.

C#
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;
}

Applies to

Produit Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1