How to debug managed code hosted in a c++ project

Hi,

My solution has a C++ Main project, and several C# projects.
The C++ project loads and runs the managed code using nethost/hostfxr

In Visual Studio I can just change the debugger type to Managed for the Main project, but this is not possible in Rider.

In the Run/Debug Configurations adding .NET Project can launch the app, but debugging doesn't work (not stopping at breakpoints).
Possible issue is that it is not possible to set a Runtime this way.

In the Run/Debug Configurations adding .NET Executable works if I manually select .NET / .NET Core as the runtime (automatic doesn't work, I suspect this is why the above option doesn't work)
This however have issues:
- I cannot start this after Build/Clean solution, because the executable doesn't exist yet, even though it would be built by Before launch.
- I cannot use $(LocalDebuggerCommand) which means the path will be locked to either the Debug or Release executable so I need 2 config to cover this and switch every time I switch between Debug / Release which introduces a point of failure.

What is the best way to set this up?

1
1 comment

Hello,

Thank you for sharing your experience. The Mixed mode debug is supported, but there is no way to start the native application with mixed debugger active from the start. Meantime, you can use the Run | Attach To Process and attach the mixed debugger to the running process that hosts the runtime. 

Here you can find sample project and recording that demonstrates how it work: JetBrains Uploads.

If that doesn't help, please tell me.

There is a corresponding feature request you might want to upvote: RIDER-132403 Mixed Mode. Provide a way to configure mixed mode debugging within CPP run configurations (including UnrealEngine/UProject run configurations)

Have a nice day!

0

Please sign in to leave a comment.