Natvis for C++/CLI Available to Preview in VS2015 Update 2

This post details how to enable the feature in VS2015 Update 2.  The recommended way of getting this feature is now to install VS2015 Update 3 which supports it by default.

In Visual Studio 2012 the native debugger significantly improved with the addition of native visualizers (natvis) as part of a major debug engine overhaul.  Adding C++/CLI code to your project would trigger the debugger to use our old debugging infrastructure as the new debugging infrastructure lacked support for C++/CLI.  We’ve heard your feedback and we’re happy to announce the first preview of the new debugging experience in Update 2 that can be enabled as described below.

Here is an example of how the debugging experience has improved for a managed object containing a native object with a std::vector<std::basic_string> as a member, first showing the pre-existing experience for context and then the much improved experience in Update 2.

Visual Studio 2015 Update 1 and earlier

oldwatch

Notice that expanding a managed object containing a native object leads to a very poor experience: std visualizers are ignored and container members are not expanding as they would in pure native application.  This is a severe limitation since it prevents easy linear viewing of any container elements and viewing meaningful data values requires multiple expansions.  The vector object below is expanded multiple times and still shows no elements, values, or even the size of the container.

Visual Studio 2015 Update 2 (after enabling in registry)

newwatch

Now the same variables in the watch window will show the proper container and member expansions as defined in the natvis visualizers.  The std::vector correctly shows its member expansions and inspecting the objects feels natural just like with pure native code, listing the size, capacity, and each element’s value.

 

How to Try It Out

Note: we now recommend upgrading to VS2015 Update 3 a this release supports the new EE by default and has bug fixes related to this feature.

We are hoping to get as much feedback as possible from C++/CLI users to make sure this improved debugging experience meets your needs.  We’d love for you try kick the tires on this greatly improved debugging experience and let us know how it’s working for you!

Due to a bug in the Update 2 RTM release, you first must download and install the micro-update KB3151378 found here:

https://msdn.microsoft.com/en-us/library/mt695655.aspx

Once the micro-update is installed, we have moved all of the fixes into a .vsix that can enable the new EE just by installing the extension: https://visualstudiogallery.msdn.microsoft.com/ab846c83-56be-41b4-88e7-95895ab528dc

The reg key mentioned in the earlier version of this post is no longer valid.  We plan to have this feature on by default for Visual Studio 2015 Update 3.

Closing Remarks

We look forward to having this as the default experience in the future and would love to hear your feedback.  Please leave comments or feel free to shoot me an email: vsdbgfb@microsoft.com if you run into any issues.