How to debug c# assemblies used in Delphi.Win32?

  • Thread starter Bart Roozendaal
  • Start date
B

Bart Roozendaal

I am using a C# assembly in Delphi.Win32 using the com interop services.
This works fine, but I am looking for a way to debug the C# assembly. When
using a Delphi program as a host for the assembly, the program quits at the
point where it uses the assembly. If I start the Delphi program itself, all
works fine, but I can't debug the C# code.

Is there a way to have the Delphi debugger step into the C# assembly when
it's loaded? Or is there an alternative debugger that will help me with that?
Any help is appreciated.

Bye,
Bart Roozendaal
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

What if you use a C# program to make the same calls (methods & parameters)
than you do from Delphi?

You can attach the debug to anther process. go to Debug/Processes and
select the process you want (from the .dll IDE ) , additionally you could
compile the external program and set it as the starting program fomr the
Project/Properties menu. I use this technique when I'm programming GIS code
 
B

Bart Roozendaal

Hello Ignacio Machin ( .NET/ C# MVP )" ignacio.machin AT dot.state.fl.us,

Thanks for answering me. I tried both attaching to the running process (gives
an error: cannot attach to this process or similar) as well as using the
Delphi program as a startup program (which causes the program to quit immediately
when calling the assembly. I haven't tried using a C# calling program as
I will assume that will work fine. The code in itself looks ok, it's just
that I want to have a decent way of debugging...

Any other suggestion you might have is much appreciated.
bart
 
B

Bart Roozendaal

Hello Ignacio Machin ( .NET/ C# MVP )" ignacio.machin AT dot.state.fl.us,

FWIW: I now tried using the assembly from a X# host program and debugging
just works fine there...
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Are you exporting it as a COM ?

If the code works fine then it's an issue with the COM visibility from
Delphi. How are you doing it?

There is a checkmark in Project/Settings that reads as "Register for COM
interop", make sure it's marked
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Bart Roozendaal said:
Hello Ignacio Machin ( .NET/ C# MVP )" ignacio.machin AT dot.state.fl.us,

FWIW: I now tried using the assembly from a X# host program and debugging
just works fine there...

Are you registering your dll for COM interop?
 
B

Bart Roozendaal

Hello Ignacio Machin ( .NET/ C# MVP )" ignacio.machin AT dot.state.fl.us,

I'm using BDS2006: there is no Project-Settings option, just Project-Options.
In the Options there is no 'Register for COM interop'. I used regasm to generate
a tlb, which I imported in the Delphi program.

In the help files, the only reference I can find to the 'Register for COM
Interop' setting is in a Visual Basic.NET example and a V# description. In
the assemblyinfo I have added the [assembly: ComVisible(true)] setting.

Does this help you?

Bye,
Bart
 
B

Bart Roozendaal

Hello Ignacio Machin ( .NET/ C# MVP )" ignacio.machin AT dot.state.fl.us,

Hi Ignacio, see other answer, but yes, I do...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top