Jul 19, 2011 5:04:29 AM
How to Debug ILM/FIM Extension Code Running Out-of-Process

Most ILM/FIM implementations require some custom code extensions, and debugging these extensions is an important part of the development process. When developing code extensions for ILM and FIM, one of the configurable options is to run your code in a separate process. This is an option for ECMA, MA and MV code extensions.

Running the extensions in-process means that the extension code is loaded into the synchronization server process (miisserver.exe). Running an extension in-process is more efficient than running it out-of-process. The downside however, is if the extension fails, it can cause the synchronization server process to fail.

Running an extension out-of-process means that the failure of the extension will not affect the synchronization server; however doing so results in a speed and resource penalty. Debugging an extension code that is run out-of-process is very difficult because the process that loads the extension loads only when needed. Often by the time you can determine the running process and attempt to connect to it, the event you are trying to debug may have already occurred.

It is commonly recommended that extensions be tested and debugged in-process. Once the extension has been tested, you change to out-of-process. However, there may be issues that occur only when running out-of-process.

One method you can use for debugging your out-of-process code is to have your code call the debugger itself.

Below is an example of using a parameter in an Extensible Connectivity Management Agent (ECMA) dll to launch the debugger. You should put this section early in the ECMA code so that the maximum number of items can be debugged.

Similar code can be added to MA Synchronization and MV Extension code, using a configuration file to turn this feature on and off. This is most often done with an XML file used to store various configuration items used in the MA and MV extension code and loaded in the Initialize methods. Invoking the debugger at this point will allow you to capture the most information.

// Optional Debugger Launch configured as MA 'Additional parameters'

try

{

launchDebugger = Convert.ToBoolean(configParameters["LaunchDebugger"].Value);

if (launchDebugger) Debugger.Launch();

}

catch (Exception)

{

// attribute is optional - continue

}

This option should only be used for testing, because until you attach a debugger and continue stepping through your code, the ILM/FIM synchronization server is paused.