views:

226

answers:

2

I have seen this for a long time, and finally decided to put the question up here. I have some applications that I need to maintain that were written in Delphi 2007 for .NET (ASP.NET 2.0). Normally, the first time I run the application (using IIS) I get the classic "Unable to start debugging on the web server. Unable to attach to ASP.NET worker process" message. I simply press F9 (run) again, and it runs. Sometimes I have to try running several times before it will actually run.

I am running Windows 7 64-bit (and have seen the same effect on Vista 64-bit). I do have IIS configured for ASP.NET, and I do have the following code in my Web.config file.

  <system.webServer>
      <modules>
         <add name="DbgConnect" type="Borland.DbkAsp.DbkConnModule,Borland.dbkasp,Version=10.5.0.0,
           Culture=neutral, PublicKeyToken=b0524c541232aae7" preCondition="managedHandler" />
      </modules>
      <validation validateIntegratedModeConfiguration="false" />
  </system.webServer>

The point is that I eventually can run the application in the debugger, sometimes even on the first try. Many times when I get the failure it happens about 15 seconds or so after I press Run, sometimes even after I've hit a page or two (or three) of the Web app. And, yes, when Delphi gets into this mode, I can simply run without debugging, and all is fine (unless I really want to debug). And, I can just keep on trying to run in the debugger and eventually it will just work.

It appears that Delphi's .NET debugger is somehow getting the idea that the application cannot run, and then gives up and stops the process (which as I've mentioned is sometimes clearly running).

I know of other developers who have also seen this behavior. My question is, does anyone know how to stop this annoying behavior?

A: 

I don't remember the exact error message, but I believe I've seen something at least similar to this in the past. All I did to fix it was run a "Repair" on the .NET 2.0 Framework (through Control Panel --> Add/Remove Programs). Then maybe restart your computer after that...

Mikey
I am currently working on a different project. When I get back to Delphi for .NET I will try this. Thanks for the suggestion.
Cary Jensen
OK, back on this project. I did a repair on the .NET 2.0 Framework SDK (that's the only .NET item in the Programs and Features applet. I'm runninng in Windows 7). Things seem to be slightly better, but I still get the behavior on a regular basis.
Cary Jensen
A: 

If you have this problem, you're going to continue to have this problem. However, here is a workaround.

Begin by running your project without debugging, and then attach to it once it is working. To do this, select Run | Run Without Debugging, or press Ctrl-Shift-F9.

Once your application is up and running, and you want to have the services of the debugger available, select Run | Attach to Process. From the Attach to Process dialog box, set the Debugger dropdown to CodeGear .NET Debugger. IIS will now appear in the Running Processes listbox. On my machine, it appears as w3wp.exe. Uncheck the Pause After Attach checkbox, and then click Attach. (After using the Attach to Process dialog box the first time, it will default to the .NET debugger and Pause after attach will not be checked.)

You are now running with the debugger enabled. If you hit a breakpoint, or encounter an exception, or select Run | Program Pause, the debugger will be loaded. If you want to disable the debugger without closing the application, select Run | Detach From Program.

Apparently, since the application is already running, whatever was giving up and giving the false error message is not involved.

On the plus size, there is a nice side effect of using this approach to debugging a Delphi for .NET application. Once you are runninng, and find a problem, you can pop into the debugger and see what's going on inside. If you find a problem to fix, detach from the proces, fix the problem, and re-compile. You can leave your application running in IIS.

Once the project has been re-compiled, the next page you hit in the application using IIS will cause the updated program to load. If you need the debugger again, simply attach to the IIS process. In other words, you an debug, fix, recompile, debug, fix, recompile,... without having to ever close the application in your browser.

Cary Jensen