IMethodReturnMessage.Exception Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the exception thrown during the method call.
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
The exception object for the method call, or null
if the method did not throw an exception.
- Attributes
The immediate caller makes the call through a reference to the interface and does not have infrastructure permission.
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.
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
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 |
Commentaires sur .NET
.NET est un projet open source. Sélectionnez un lien pour fournir des commentaires: