Unable to debug C++/CLI dll using visual studio 2022 mixed mode (.NET Core, .NET 5+, native code)

46 Views Asked by At

I have an app whose exe starts on native (c++) code. This eventually calls into an intermediary c++/CLI dll which has /clr:netcore option enabled. This intermediary layer then goes into a .NET 8 dll which has much of the application logic.

Using the following options on visual studio remote debugger: enter image description here

I am unable to debug the native code OR the C++/CLI code at the start of the application. I get the following error when I try to break in the native / C++/CLI code:

enter image description here

The symbols get loaded in:

enter image description here

But I am not able to attach. Eventually the process ends with the following error:

"The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core."

When I try and debug with "Managed (.NET 4.x) code, Native code" I am able to attach to the native code BUT the symbols for C++/CLI do not load because it uses netcore:

enter image description here

I have an issue somewhere in the C++/CLI code, so I am not able to get to the .NET 8 code. Due to this I am blocked. Any way to debug the C++/CLI code here?

EDIT:

I was able work around this by just loading into my C++/CLI dll right after I launched my executable. This allowed me to load the CLR and debug into my native code.

0

There are 0 best solutions below