Search Wiki:
Resource Page Description
ExceptionFilterInject is a tool which modifies the IL in a managed-only dll to provide exception filter support for languages (such as C#) which do not have exception filter support.

Exception filters provide the ability to run arbitrary code during the 'handler search' phase of exception processing. This is especially useful to allow you to (1) catch all non-critical exceptions in your top-level exception filter without needing to also catch exceptions that should be reported as bugs (such as NullReferenceException) -and- (2) allow you to save a minidump of the exception or report the exception to Watson.

This project also contains a sample which uses exception filters in managed code to control which exceptions are caught and to save a minidump.

How to use this tool:
1. In any place where you would like to add an exception filter, simply add a try/catch, and catch System.Execption (in other words, create a try/catch which catches all exceptions).
2. Define a static public or internal function which returns a 'bool' and takes the Exception as an argument (ex: static bool MyFunction(Exception exception)). The bool indicates if the exception filter should be caught.
3. Build your assembly
4. Run your assembly though this tool

Tool Syntax: ExceptionFilterInject.exe <inputassembly> <filterfunction> <output_directory> intermediate_directory
filter_function uses the IL Assembly syntax for function names (ex: MyNamespace.MyClass::MyFunction).

Example: ExceptionFilterInject.exe c:\myproj\myassembly.dll MyNamespace.MyClass::MyFunction c:\myproj\bin %tmp%
Last edited Apr 21 2008 at 9:26 PM  by greggm, version 3
Page view tracker