No native code debugging in CoreCLR console applic

2020-04-27 05:33发布

问题:

I really want to jump all over CoreCLR. The new project structure, the merging of nuget into the build system, the automatic refreshing of solutions when the file system reports changes, and the targeting of multiple platforms are just some of the reasons I want to move on from the old csproj/.net 4.x stuff.

One of my primary use cases is exploring multiplatform game engine design with C#, but there's some interop involved for specific platforms (hidden away in SharpDX in my case) - debug messages that come from the unmanaged side of DirectX bubble up from native code into managed code if you "enable native code debugging" in the project's debug options. CoreCLR projects don't have that option though in the project's debug settings, which means no useful debug messages, which means debugging DirectX calls is nightmarish.

I'd appreciate some insight into what's going on in this regard.

回答1:

The tooling doesn't have support for native debugging when running from VS. However, if you attach the debugger manually to the process, select both native and CoreClr (the option is in Debug -> Attach to Process) and you'll achieve what you want.

If you are using dnx then you can pass the --debug flag when the app starts, similar to this:

dnx --debug . run <args>

and it will wait for the native debugger to be attached.

PS: Caveat: if you pass --debug you must attach a native debugger. You cannot attach only the managed one.