IMethodReturnMessage.Exception Eigenschap
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee wordt de uitzondering gegenereerd tijdens de methode-aanroep.
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
Waarde van eigenschap
Het uitzonderingsobject voor de methodeaanroep of null als de methode geen uitzondering heeft gegenereerd.
- Kenmerken
Uitzonderingen
De directe beller voert de aanroep uit via een verwijzing naar de interface en heeft geen infrastructuurmachtiging.
Voorbeelden
De volgende voorbeeldcode toont een aangepaste proxy die RealProxy.Invoke overschrijft om de retourberichtgegevens te schrijven, inclusief of de methode een uitzondering heeft veroorzaakt.
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