Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I debug a C# COM assembly when it's being called from a native win32 application?

I'm developing a C# assembly which is to be called via COM from a Delphi 7 (iow, native win32, not .net) application.

So far, it seems to work. I've exported a TLB file, imported that into my Delphi project, and I can create my C# object and call its functions.

So that's great, but soon I'm going to really want to use Visual Studio to debug the C# code while it's running. Set breakpoints, step through code, all that stuff.

I've tried breaking in the Delphi code after the COM object is created, then looking for a process for VS to attach to, but I can't find one.

Is there a way to set VS2008 up to do this? I'd prefer to just be able to hit f5 and have VS start the Delphi executable, wait for the C# code to be called, and then attach itself to it.. But I could live with manually attaching to a process, I suppose.

Just please don't tell me I have to make do with MessageBox.Show etc.

like image 250
Blorgbeard Avatar asked Sep 24 '08 12:09

Blorgbeard


People also ask

Is debug hard C?

Compared to other programming languages, C can be a more difficult language to debug and figure out errors within code, no matter if it is logic or syntax-based.

How do I debug C in Visual Studio?

To do that, open C++ file in VSCode and either hit F5 or go to Debug -> Start Debugging and select C++ (GDB/LLDB) then select g++.exe build and debug active file . Notice that I've added one more optional configuration g++ build & run active file in launch. json and g++ build & run in tasks.

How do I run debug mode?

Run the program in debug modeClick the Run icon in the gutter, then select Modify Run Configuration. Enter arguments in the Program arguments field. Click the Run button near the main method. From the menu, select Debug.


1 Answers

In the VS2008 project properties page, on the Debug tab, there's an option to set a different Start Action.

This can be used to run an external program (e.g. your Delphi app) when you press F5.

like image 64
Mark Pattison Avatar answered Oct 11 '22 23:10

Mark Pattison