PostSharpAPI ReferencePost­Sharp.​AspectsMethod­Execution­ArgsException
Open sandboxFocus

MethodExecutionArgs.Exception Property


Gets or sets the exception thrown by the target method.

public Exception Exception { get; set; }
Property Value
Type Description

An Exception, or null if the method is exiting normally.


This property is only available inside the OnException(MethodExecutionArgs) and OnException(MethodExecutionArgs) advices.

You can replace the exception by setting this property and also setting FlowBehavior to ThrowException. You can also throw a new exception from the advice if you need to replace the current exception.