1

i have gui written on delphi, i made comvisible assembly from .net assembly, and i'm invoking it from delphi, it works. but i can not step into my .net assembly. i putted executing delphi_project.exe at compiling of dll, delphi_project.exe begins to work, and my breakpoints at .net dll become unreachable. how can i fix it?

edit: vs2010 ult

2
  • Could you please let us know which tools you are using. Delphi .net? Native Delphi? Delphi Prism? Visual Studio? And which debugger? Commented Mar 8, 2011 at 16:33
  • From what was said above (com object made visible then imported into Delphi), I suspect this is plain native Delphi. We don't know the version. But it won't change anything: it's not possible to mix such breakpoints - see my Answer. Or perhaps I missed some magic tool, but I've never heard of such tool. Commented Mar 8, 2011 at 21:06

1 Answer 1

1

It's not possible, because of the design of the dot net virtual machine.

Dot net code is managed, running in a virtual environment, not natively on the machine.

Even if the Dot net code is compiled (whereas it could be interpreted), it's not directly compiled into a native Windows executable: it's compiled into CIL, then interpreted or converted into x86 op codes by the CLR, which op codes are run inside a virtual environment.

This make it very reliable about security and allow some high-level tricks like RTTI or garbage-collection, but it's NOT a process like any other.

So you can't just pass from your Delphi executable (which is a true Windows executable) into the DotNet code. You can do that with C or C++ code (if you have all the debugging information, and did compile it with Borland C++ builder), but you can't do that with DotNet code.

You can try step by step debugging in the Delphi asm view (shortcut is Alt-F2), but you'll spend a lot of time in the mscoree.dll library, and you will never know which line of you DotNet program you're executing. I suspect you'll be like me: sinking in the asm code... we are humans, no x86!

So to debug your application:

  • add logging to both side (Delphi+DotNet)
  • create a pure DotNet skeleton application, just big enough to call the DotNet code you want to test: this will allow you to debug your DotNet code
  • even better, write automated tests: your DotNet code should be tested from DotNet side, with some regression tests - then it will integrate and work as expected when called from Delphi

Last trick: if you want to make your DotNet code run under 64 bit OS without any problem, don't target your assemblies to the right target, because, when run from a Delphi application, it will be executed inside Wow64, since Delphi executables are still 32 bit.

EDIT: PERHAPS A SOLUTION

After some sleep, an idea came to me: in the Delphi IDE, you can attach a process to the debugging. Perhaps it could be possible to do the same with the Visual Studio IDE.

And it sounds feasible: you can attach the Visual Studio debugger to any running process, via some menu of the IDE.

The Visual Studio debugger has the ability to attach to a process that is running outside of Visual Studio. You can use this attach capability to do the following:

  • Debug an application that was not created in Visual Studio.
  • Debug multiple processes simultaneously. You can also debug multiple processes by starting multiple projects within a single solution.
  • Debug a process running on a remote computer.
  • Debug a DLL that runs in a separate process that cannot easily be started from Visual Studio, for example, a service or an ISAPI DLL running with Internet Information Services.
  • Start the debugger automatically when a process crashes while running outside of Visual Studio. This is Just-In-Time debugging.

Source: http://msdn.microsoft.com/en-us/library/3s68z0b3.aspx

Sign up to request clarification or add additional context in comments.

2 Comments

Since the one tool that OP mentions is VS, I'm not sure this helps. My guess is that OP wants to debug the .net DLL in VS and this is what is failing. But it's all guesswork until the OP decides to supply some details.
What I understood is that he has some Delphi GUI application calling some logic coded in a Dot Net library exported as COM. He would like to debug the Dot Net library, but he can't do it from the Delphi IDE. So he wanted to debug it from the VS IDE. I edited my answer with a possible solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.