2

Possible duplicate of this question.

I have a MFC project that uses /clr switch and some C++/CLI code to use a .Net component. Originally this was on VS2005.

On upgrading to VS2012 Update 2, during debugging, no values or types were shown for native data types. I learned that a new mechanism for native data type visualization (natvis) was introduced in VS2010 and extended / enhanced in VS2012. Following the information on that page, I unchecked Managed C++ Compatibility Mode and C/C++ edit and continue. After this, breakpoints became disabled and stopped being hit. Using "Only Managed" debugger, the breakpoints were hit but no values were shown.

Finally, I used "mixed" debugger and used __debugbreak() to force a break. This resulted in only integer values being shown ONLY if they are local autos; and data types were picked up correctly. However, std::string or CString values are not shown and instead their type is shown in value column. Similarly, pointers, class members, or functions argument values are not shown and type information, Undefined value, or out of scope is shown in the value column.

The behavior is consistent across autos, locals and watch windows as well as mouse hover on symbols.

How do I get the native data types to display their values during debugging in VS2012 mixed mode C++/CLI MFC application.

I have read this question and verified that all symbols have been loaded in modules window.

Apparently, Microsoft is aware of the issue and the upcoming CTP of Update 3 should fix it.

Additionally, why do I need to use __debugbreak()?

Community
  • 1
  • 1
  • @knockNrod - We tried using only VS2012 and VS2012 with Update1. Debugging was unusably slow - each F10 takes 1-2 minutes to proceed to next line. This is a [known](https://connect.microsoft.com/VisualStudio/feedback/details/751327/debugger-stepping-in-mixed-mode-application-is-very-very-slow) [issue](http://connect.microsoft.com/VisualStudio/feedback/details/774026/debugger-hangs-in-managed-code-in-mixed-mode-c-app) with VS2012 for mixed mode debugging. – Chandra Prakash Apr 27 '13 at 08:06
  • @Per Lundberg - Thanks a ton. Confirmed that Update 3 RC solves slowness as well as native symbol values. However, debugger has to be manually changed to "Managed Only" otherwise breakpoints are not hit. On breaking using `__debugbreak()`, symbols are not shown. – Chandra Prakash May 14 '13 at 12:07

2 Answers2

2

A couple of days ago, Microsoft released a Visual Studio Service Pack 3 RC which may help (installing it myself right now). Here is the link: http://www.microsoft.com/en-us/download/details.aspx?id=38832

Per Lundberg
  • 3,837
  • 1
  • 36
  • 46
  • Can confirm that displaying unmanaged variables in the debugger now works, at least for me, after having installed the above. – Per Lundberg May 11 '13 at 05:52
  • Thanks Per. Confirmed that Update 3 RC solves slowness as well as native symbol values. However, debugger has to be manually changed to "Managed Only" otherwise breakpoints are not hit. On breaking using `__debugbreak()`, symbols are not shown. – Chandra Prakash May 14 '13 at 12:05
  • FWIW, SP3 is now released (it's no longer an RC). – Per Lundberg Jul 29 '13 at 05:25
0

Re-install Visual Studio 2012 and do not apply Service Pack 2.

knockNrod
  • 353
  • 2
  • 10