After looking around, it seems like won't happen in a mixed mode debugging session. The Visual Studio debugger will only allow you to set a data breakpoint if the debugger is the native C++ debugger. This means if the start up project is a C# project then you just can't set them.
There is a post from all the way back in 2008 where a debugger program manager mentioned this. I also can't find any mention of this being changed during the last 12 years.
There does seem to be sneaky ways of getting the debugger into native mode by selecting the C++ DLL project as the start up project and setting the C# executable as the start up command, also being sure to set the C++ debugger type to native only. This has the obvious problem of not being able to debug the managed side of the application though. But there seems to be no way to set C++ data breakpoints in the way you want to.
Visual Studio 2019 C++ debugger won't let me set data breakpoints
I'm debugging native C++ code in a native DLL that is being called from a .NET assembly at run time.
Under Debug > New Breakpoint and Breakpoint window New button, Data Breakpoint is grayed out.
I know this feature is available only for native-code debugging. Does that mean I can't use it in native code within a .NET application?
Or is there something else I should try?
2 answers
Sort by: Most helpful
-
Darran Rowe 1,031 Reputation points
2020-08-18T03:45:12.317+00:00 -
Dylan Zhu-MSFT 6,421 Reputation points
2020-08-18T09:14:15.2+00:00 Hi NormBirkett-8967,
Except for native C++ project, you can just set data breakpoint in .Net core 3.0 or higher project. When the debugger breaks at one breakpoint, you could right-click the value in Watch(/Autos/Locals) window, then select 'Break when value changes'. But you still cannot set it in Debug/New Breakpoint/Data Breakpoint.
In addition, please note that the data breakpoint does not apply to:
- Properties that are not expandable in the tooltip, Locals, Autos, or Watch window
- Static variables
- Classes with the DebuggerTypeProxy Attribute
- Fields inside of structs
Best Regards,
Dylan