2

We have a native program, written in Delphi 2007, a Win32 .EXE file.

This program hosts the .NET runtime, and loads a bunch of assemblies we've written.

So if I copy that executable into the bin\Debug directory, configure the .NET project with which executable to start, I could debug this in 2008. Basically, breakpoints in .NET assemblies would show up with a hollow circle until the point where the program loaded up the .NET runtime and loaded my assemblies, at which time they became functional breakpoints and they would break at the right point, etc.

Basically, debugging worked if I used Visual Studio 2008 for this.

Now I tried upgrading the projects with Visual Studio 2010, and it doesn't. The breakpoints are still showing as hollow circles, but now an additional yellow warning sign is shown telling me that no symbols have been loaded.

Yet, changes to the code actually execute. If I add a messagebox to a particular method, the message will be shown when running the program, but breakpoints on or near that line doesn't stop the debugger.

I've gone through the debugging options dialogs and can find no differences between 2008 and 2010. There's a couple of new checkboxes in the 2010 dialogs, so I've tried with all combinations of those, no dice, still no functioning breakpoints.

Has anyone else done anything like this and know what I have to tweak?

Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825

2 Answers2

1

It could be, depeding on what runtime you are using, that VS2010 is kicking off the exe and the .net part in seperate processes. Since studio is attaching to the exe process, if the .net component is indeed running in a seperate process, then the things you are seeing would apply. Try manually attaching to the .net process to see if that helps.

Here is a similar question, but nUnit is the exe rather than your dephi app. I suspect you problem is somewhat related.

UPDATE: Take a look at this solution. You may need to add a config to tell studio to use the non- 4.0 runtime like this:

<?xml version="1.0"?>
<configuration>
  <startup>
    <supportedRuntime version="v2.0.50727"/>
  </startup>
</configuration>

Here is a post describing the problem, and a more official post on the MSDN Blogs.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Mike Ohlsen
  • 1,900
  • 12
  • 21
  • It isn't running in a separate process, the Win32 application hosts the COM objects for the .NET runtime inside itself, which gives it a very close relationship with the .NET classes. This wouldn't work if it was cross-process. The application still runs and loads (I can see memory usage goes up and with process explorer I can see that it has loaded both the .NET runtime and our assemblies.) It is definitely executing as before. – Lasse V. Karlsen Nov 18 '10 at 13:55
  • Googling for this, I am seeing many people with problem debugging after upgrading to VS2010. Some mention hosting in COM, others in delphi. Some people report when launching the exe as you are, it fails, but when launching without debugging, and then attaching it works. Give that a try. – Mike Ohlsen Nov 18 '10 at 14:00
  • updated my answer with more details and links to others having similar problems. – Mike Ohlsen Nov 18 '10 at 14:13
  • I will look through the links, but the runtime specification is not needed. We load the 2.0 runtime specifically inside the program before loading our assemblies, and I've already verified that the correct runtime is loaded. – Lasse V. Karlsen Nov 19 '10 at 08:17
  • right, your app is loading the 2.0 runtime, but i think the hint is for studio, to tell the debugger that it needs to attach to the 2.0 runtime instead of 4. – Mike Ohlsen Nov 19 '10 at 12:55
1

Check these settings: alt text

Workaround: Try you attach to the application manually and specify to debug Managed Code also:

Step 1

Debug window

Step 2

Debug options

Bogdan Maxim
  • 5,866
  • 3
  • 23
  • 34