I am trying to debug an ISAPI extension written in Delphi. The extension works just fine, however I can't seem to debug it (ie set a breakpoint and singe-step the code).
Here is what I have done:
However the breakpoint is never triggered in my handler (see pic below):
To debug an ISAPI extension using Visual StudioLaunch Visual Studio. In the Build menu, click Start Debug and click Attach to Process. Select the Show System Process check box. If your ISAPI extension is running in the IIS process, select the Inetinfo.exe process from the list and click OK.
Debugging delphi source files You need to go to "project->options->compiler" on this tab you need to check the "use debug DCUs". After that you need to build your project again and you can run your application. From now on breakpoints also stop in Delphi source files.
Your approach has a limited utility because you can only start debugging AFTER your application has started. If you need to debug it from the first request, this is useless. This is how you should do:
IIS Setup:
1) On IIS, create a new web application under Default Web Site.
2) Every application under Default Web Site should be using the same application pool, DefaultAppPool. Make sure that this application pool is able to run an ISAPI application without debugging. If you can't run an ISAPI application using it, you won't be able to debug it either.
Application Setup (Delphi IDE):
Setting up the application in Delphi (any XE+ IDE has similar settings)
1) Run Delphi as administrator. Not absolutely required but makes lots of things easier and avoids lots of issues.
2) In Delphi Ide, choose Run -> Parameters. Inform Host application and Parameters as you can see in the following picture:
W3WP.exe is the IIS Worker Process executable, and we will run it interactively to debug the ISAPI app. Remember that 2 versions of w3wp.exe exist: one 32-bit under C:\Windows\SysWow64 and another 64-bit under C:\Windows\System32. You must use the correct version that matches your application.
3) Stop World Wide Web Publishing Service. You may use "net stop W3SVC" from an elevated command prompt, or use the Windows services console.
Once the W3SVC is stopped, just run the application from Delphi IDE and call it from your browser. When the application should load and all your breakpoints will be activated. You can debug like any other Delphi application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With