The break point in a "WinRT Component DLL" is not hitting while debugging a C# UWP app

169 views Asked by At

I referred a "Windows Runtime component(Universal Windows) C++" project in a "Black App(Universal Windows) C#" project.

I set a break point in the "Windows Runtime component(Universal Windows) C++" project. But the break point never hits and i can not step into C++ codes from C#.

The options of my VS2019 version 16.8.3 enter image description here

enter image description here

I found Debugging a WinRT Component DLL while running a C# Metro App RRS feed and created a file called ".csproj.user" and put it in the same folder as the ".csproj" file.

But it does not work!

Any advice?

1

There are 1 answers

0
Jeff Spencer On

Generally when I encounter this problem it's because the debugger is debugging in the wrong mode. For instance I'm trying to debug Managed code but the debugger is attached in Native debugging mode. I don't know how to select the debugging mode when launching the debugger automatically. But if you launch the application without the debugger then select "Debug -> Attach To Process" you will be able to select your desired debugging mode when selecting the process. "Automatically determine the type of code to debug" often doesn't work for me. And debugging both Native and Managed seems rather hit and miss for me. So sometimes often I select only one mode until I've got break points working correctly in the mode I need.

Today I discovered a new case where I couldn't hit breakpoints in my code. So I'm adding the information here. I was unable to get a breakpoint to stay red (active) in Visual Studio 2019 when debugging C/CLI code. Which is a mix of native C++ and C#. To get things working I had to disable "Enable Edit and Continue" in under Tools -> Options -> Debugging -> General. Also, when I attached to the process I used "Managed Compatibility Mode" plus the managed .net version I was building with. So "Managed (.Net 4x) code". I'm not sure if the last change is necessary or not. But I wanted to update this before I forgot all about it.

A second reason I sometimes can't hit breakpoints is when the code loaded doesn't match my symbols. I use the debug window "Modules" to see if the symbols have loaded. If they haven't, I check to see if the time and date of the file loaded matches what I just built. Right clicking the module and selecting "Symbol Load Information..." is also useful when symbols aren't loaded. As this lists where the compiler is searching for the symbols.