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

I am developing a C # assembly that should be called via COM from a Delphi 7 application (iow, native win32, not.net).

While this is working. I exported a TLB file imported into a Delphi project, and I can create my C # object and call its functions.

So, this is great, but soon I'm going to really want to use Visual Studio to debug C # code while it works. Set breakpoints, execute code, all this.

I tried hacking Delphi code after creating a COM object and then looking for a process to connect VS, but I can not find it.

Is there any way to install VS2008 for this? I would rather just hit f5 and make VS launch the Delphi executable, wait for the C # code to be called, and then attach it to myself. But I could live with manual connection to the process, I suppose.

Just please do not tell me that I should communicate with MessageBox.Show, etc.

+6
c # windows delphi com
source share
3 answers

On the VS2008 project properties page, on the Debug tab, it is possible to set another Start action.

This can be used to run an external program (for example, your Delphi application) when you press F5.

+10
source share

In the method you want to debug, specify the following:

#if DEBUG if (!System.Diagnostics.Debugger.IsAttached) Debugger.Launch(); #endif 

When you want to debug, create a debug version and use it in your application. When this code is run, a dialog box appears asking if you want to attach the debugger.

+9
source share

You can simply connect to the native application and see, as a rule, a breakpoint, viewing stacks, hours, etc. After creating the COM object, you need to connect.

I put Afx MsgBox when the object is created to stop the application flow and then attach the debugger.

+1
source share

All Articles