There are several ways to establish an environment for debugging your server components and Internet Server extension DLLs when using IIS 4.0 or later. These procedures are described in the following sections:
Debuggers Capable of Attaching to Windows NT Processes
If you are using a debugger capable of attaching to a Windows NT process, you can use this functionality to debug your component or extension.
To debug an IIS 4.0 or later DLL with Visual Studio
- Start the iisadmin process. This can be done from the command line with the command
net start iisadmin. You can also use the Services dialog box from Control Panel to start the IIS Admin Service, which will start iisadmin. - In Visual Studio, choose Processes from the Debug menu.
- In the Processes dialog box, select the Show system processes check box.
- In the Available Processes box, select the inetinfo process.
- Click the Attach button.
- In the Attach to Process dialog box, make sure Native is selected under Choose the program types that you want to debug.
- Start the World Wide Web Publishing Service (w3svc). You can do this from the command prompt, using the command
net start w3svc, or you can use the Services control panel:
- From the Start menu, click Settings and choose Control Panel.
- In Control Panel, double-click Administrative Tools.
- In the Administrative Tools window, double-click Services.
- In the Services dialog box, right-click World Wide Web Publishing Service and choose Start from the shortcut menu.
Debuggers that Cannot Attach to Windows NT Processes
If you are using a non-Visual Studio debugger that cannot attach to a Windows NT process, take the following steps to establish an appropriate debugging environment.
To debug an IIS 4.0 or later DLL with a non-Visual Studio debugger
- In Control Panel, open Services.
- Select the IIS Admin service and click the Startup button.
- Select the Allow Service to Interact with Desktop check box and click OK.
- Repeat steps 2 and 3 for all processes that run under the IIS Admin process, for example World Wide Web Publishing Service and FTP Publishing Service.
- Use the Registry Editor (REGEDIT) to add a subkey named Inetinfo.Exe to the HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\Image File Execution Options key.
- Add the following entry to this new key:
Debugger = <DebuggerExeName> where DebuggerExeName is the full path to the debugger you are using.
When the World Wide Web Publishing Service is started, your debugger will also be launched. You can now set appropriate breakpoints in your Internet Server extension DLL.
Setting Breakpoints in a Component's Source Code
Depending on the language you are debugging, you may not be able to set breakpoints in a component's source code until the component has been loaded into memory.
To set and trigger breakpoints
- Start Internet Explorer and view the .asp page containing the object.
As soon as the page is loaded, you should be able to set breakpoints in your component.
- Click Refresh to view the page again and trigger the breakpoints you selected.
If the component cannot be loaded even once (for instance, if the fault occurs in component startup code), you need to load the component DLL prior to starting the debugging session (Steps 11-14 below).
Establishing Windows NT Security Privileges and Debugging an IIS 4.0 DLL
In some cases, you may not be able to use the procedures outlined above. If you have difficulty using these strategies, there is a third approach, which has been described in previous releases of IIS. This approach requires establishing Windows NT security privileges as well as making changes to the registry. It will also disable your ability to run IIS as a service. This approach should only be used if the previous two strategies have failed.
To establish Windows NT security privileges and debug an IIS 4.0 DLL
- 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 Windows NT account you will use when debugging the Internet Server extension DLL.
- Use the Distributed COM Configuration utility (DCOMCNFG) to change the identity of the IIS Admin Service to the user account you will use for debugging.
- 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.
- 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.
- In Visual Studio, select the project in the Solution Explorer.
- From the View menu, select Property Pages.
- In the Property Pages dialog box, under the Configuration Properties folder, select the Debug page.
- In the Command field of the properties grid, type:
C:\WINNT\System32\Inetsrv\Inetinfo.exe
- In the Command Arguments field of the properties grid, type:
-e w3svc
- Open the Linker folder.
- In the Output File field, type the name and path of the Internet Server extension DLL you are debugging.
- Click OK.
- To begin debugging, select Start from the Debug menu.
Note After you have completed the debugging session, you must reverse steps 5 through 1 to restore the previous settings and allow IIS to run as a service.
See Also
Debugging an ISAPI Application | Debugging Visual C++