ExceptionDispatchInfo.SetRemoteStackTrace(Exception, String) Method

Definition

Stores the provided stack trace into the specified Exception instance.

public:
 static Exception ^ SetRemoteStackTrace(Exception ^ source, System::String ^ stackTrace);
public static Exception SetRemoteStackTrace (Exception source, string stackTrace);
static member SetRemoteStackTrace : Exception * string -> Exception
Public Shared Function SetRemoteStackTrace (source As Exception, stackTrace As String) As Exception

Parameters

source
Exception

The unthrown exception.

stackTrace
String

The stack trace string to persist within source. This is normally acquired from the StackTrace property of the remote exception instance.

Returns

The source exception instance.

Exceptions

The source or stackTrace argument was null.

The source argument was previously thrown or previously had a stack trace stored into it.

Remarks

This method populates the StackTrace property from an arbitrary string value. The typical use case is the transmission of Exception objects across processes with high fidelity, allowing preservation of the exception object's stack trace information. .NET does not attempt to parse the provided string value.

The caller is responsible for canonicalizing line endings if required. ReplaceLineEndings() can be used to canonicalize line endings.

If the caller provides untrusted input to this API, this may result in the exception's stack trace containing embedded null characters, reserved HTML or JSON characters, or other unexpected values. Applications that display an exception's details to the user should always take care to encode the exception information at the point where it's displayed.

Applies to