Dotfuscator User's Guide
Exception Actions

In addition to sending exception report messages to the managed service, the ExceptionTrack attribute can be used to inject code to perform a call back to a user-specified method when an exception is detected.

Exception Notification

To accomplish this, the ExceptionTrack attribute is used to specify an ExceptionNotificationSink, which Dotfuscator uses to generate code that forwards the detected Exception object back to the application. The ExceptionNotificationSink may be a writable field or settable property of type System.Exception, or it may be a method or delegate with the signature void(System.Exception). After an exception is detected, the generated code sets the field or property value to the Exception object that was captured. If using a method or delegate sink, the generated code will call this sink with the captured Exception object as the only parameter. The application is free to react in any way in response to a detected exception. The ExceptionTrack attribute defines three properties for specifying an ExceptionNotificationSink:

These properties are described in detail in the ExceptionTrack section of the custom attribute reference.

The exception notification sink settings are optional. If they are omitted, no custom action will occur when an exception of the configured type is detected.

 

Sample ExceptionTrack attribute usage with ExceptionNotificationSink as method defined in the same class as the attributed method:

ExceptionTrack usage with ExceptionNotificationSink as method
Copy Code
[ExceptionTrack(
   ExceptionNotificationSinkElement = SinkElements.Method,
   ExceptionNotificationSinkName = "Response"
)]
private void Foo() {
  ...
}

// Respond to a detected exception
public void Response(System.Exception e) {
  ...
}

 

 


© 2016 PreEmptive Solutions, LLC. All Rights Reserved.

www.preemptive.com