Establishing a Debugging Environment
for IIS 4.0 ISAPI Applications

The following document was provided by Microsoft. I'm reposting it with the final solution that worked for me with minor corrections to the original as well as a pair of .REG files to set and unset the registry for debugging.

Rick Strahl - http://www.west-wind.com/

This method allows debugging IIS directly from the VStudio environment, where you can simply run IIS from the Debug menu and then set breakpoints on your code when it gets called. Although, there are mechanisms for attaching to the INETINFO service directly, this is tedious as hell and causes IIS to go unstable, so I prefer the method outlined below.

This approach requires the establishing of NT security privileges as well as making changes to the registry. It will also disable your ability to run IIS as a service unless you reverse the registry settings. Two registry files (one to set and one to unset) that automate the registry hacks can be downloaded from http://www.west-wind.com/files/IIS4Debugging.zip .

  1. Use the User Manager for Domains administration tool (USRMGR) to add the Log on as Service, Act as part of the operating system and Generate security audits rights on the local computer to the NT account you will use when debugging the ISAPI extension.

  2. Use the Distributed COM Configuration utility (DCOMCNFG from the Run menu) to change the identity of the IIS Admin Service to the user account you will use for debugging.

    Note: Steps 3 and 4 can be replaced by using the k2Process.REG file from above


  3. Use the Registry Editor (REGEDIT) to remove the LocalService keyword from all IISADMIN-related subkeys under HKEY_CLASSES_ROOT/AppID. This keyword may be found in the following subkeys:

    {61738644-F196-11D0-9953-00C04FD919C1} // IIS WAMREG admin Service
    {9F0BD3A0-EC01-11D0-A6A0-00A0C922E752} // IIS Admin Crypto Extension
    {A9E69610-B80D-11D0-B9B9-00A0C922E750} // IISADMIN Service


    The LocalService keyword may be found in additional subkeys of AppID.


  4. Add LocalServer32 subkeys to all IISADMIN related subkeys under the CLSID node of the registry. This will include subkeys corresponding to all of the subkeys you removed in the previous step. Set the default value of these new keys to <path>\inetinfo.exe -e w3svc. (<path> is normally "c:\winnt\system32\inetsrv".)

    Stop the WWW and FTP services from the Microsoft Management Console, or from the Services dialog box in the Control Panel.

  5. You also need to kill the IISAdmin service which also runs in INETINFO.EXE. Do this either from the Services CP applet, or better yet skip steps 5 and 6 and simply do KILL INETINFO with KILL.EXE from the NT Resource Kit. Make sure INETINFO is NOT running in task manager before proceeding!

  6. Start Visual Studio and select the Debug tab in Project Settings window.

  7. Enter C:\WINNT\System32\Inetsrv\inetinfo.exe in the Executable for debug session field.

  8. Enter "-e w3svc" in the Program Arguments field.

  9. Select the Link tab in the Visual Studio Project Settings Window.

  10. Enter the name and path of the ISAPI extension you are debugging in the Output file name field.

  11. Optionally, add your component DLL to the list of Additional DLLs that are loaded before the application starts. This will allow you to set breakpoints in component startup code.

  12. Click the Go button to start the debugging session.

  13. After you have completed the debugging session, you must reverse steps 4 and 3 to reset the registry to force IIS to run as a service again. You can change the registry or use the k2Service.reg file.

  14. If your server is a production server also remove the special user rights assigned in step  1 and 2.