Switching to Managed Compatibility Mode in Visual Studio 2013

Switching to Managed Compatibility Mode in Visual Studio 2013

Rate This
  • Comments 25

In Visual Studio 2012, we introduced a new managed debug engine that provides us the ability to more rapidly add new features compared to the older implementation. This can be seen by the number of features introduced in Visual Studio 2013 after only a single year including Managed Return Values, .NET 64-bit Edit and Continue, Async Callstacks Enhancements, and Improved Tasks Window to name a few. Unfortunately, there are still a couple scenarios that are not supported yet with the new debug engine, so in these cases you will have to switch back to the legacy engine.

To most Visual Studio developers, the current debug engine should only have a positive impact and you need not worry about what happens under the covers. While eventually we plan to completely replace the legacy engine, there are still
two scenarios where it is needed. In this blog post, I will show you how to switch to managed compatibility mode, which you should do ONLY if you have interest in the two scenarios that the current engine does not yet support.

  1. You are using a .NET language other than C#, VB, or F# that provides its own Expression Evaluator (this includes managed C++)
  2. You want to enable Edit and Continue (EnC) for C++ projects while mixed mode debugging

If these scenarios do not apply to you, there is no need for you to switch back to the legacy debug engine.

[DISCLAIMER] Enabling Managed Compatibility Mode will disable many features that depend on the current debugger implementation to operate. It is our goal in the future to completely remove the legacy engine from the product and hence remove the options discussed later in this blog post.

With the disclaimer out of the way, and only if you care about the two aforementioned scenarios in VS2013, please feel free to read on to find out how to enable the legacy managed debug engine through the global options, for an EXE project, during attach, and manually through the project file.

Global Options

To switch back to the legacy debug engine globally, select Tools/ Options ...

 

then check Use Managed Compatibility Mode on the Debugging / General tab.

The global option will force the legacy engine to be used for any launch or attach.

EXE Project

The exe project system is used when the user invokes File / Open Project, and then selects an existing exe file. To specify the legacy debugger engine, choose Project / Properties and then set the Use Managed Legacy Engine to Yes on the General project property page. This setting takes precedence over the Tools / Options setting.

 

Attach to a Process

To specify the legacy debug engine when you attach to a process, choose Debug / Attach to Process. window

 Then click the Select button on the Attach to Process dialog.

 On the Select Code Type dialog, make sure the right version of Managed code is selected, and then select Managed Compatibility Mode.

 

 

Through the .csproj/.vbproj file

Hand editing the .csproj/.vbproj, by adding the ‘DebugEngines’ property within ‘PropertyGroup’, you can force the project to use the legacy debugger engine. To enable managed compatibility mode, define the property like this:

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

<DebugEngines>{351668CC-8477-4fbf-BFE3-5F1006E4DB1F}</DebugEngines>

<FileAlignment>512</FileAlignment>
</PropertyGroup>
 
 

NOTE: If your project is using the Visual Studio hosting process (the default for many project types), you must disable the hosting process for this fix to correctly change the debug mode. To disable the hosting process go to the Debug pane on the project properties page, and uncheck "Enable the Visual Studio hosting process"

In Closing

We hope that if you require managed compatibility mode, one of the above options will meet your needs. We are currently working hard to enable these capabilities in the current debug engine.

If any of you have feedback or questions about this, please let me know in the comments section below or in our MSDN forum.

Leave a Comment
  • Please add 6 and 7 and type the answer here:
  • Post
  • @ I_C

    It might, as it's a broader fix.

    Would you mind sending me a repro (I can't repro these) so I can check to make sure? You can email me at vsdbgfb@microsoft.com

  • In a mixed C++ Windows Forms App in 2013 the debugger can't even resolve a simple std::wstring. Can this be fixed? To reproduce, open a C++ Windows Forms App or create one and declare a std::wstring in the form constructor. When debugging you can't see it's value.

  • @Adam Bruss

    Thanks for pointing this out, we will investigate this and let you know.

    Also - is there an reason you posted this issue here? Does it repro with/without Managed Compatibility mode?

  • Hi Maria,

    The problem happens if Managed Compatibility mode is on or off. I've created a Microsoft Connect issue here.

    connect.microsoft.com/.../cant-look-at-std-wstring-value-in-c-windows-forms-application-form-constructor

    I posted here because it looked like you were actively fielding issues and it's somewhat related. This worked in Visual Studio 2008. It didn't work in Visual Studio 2012. We were hoping it would be fixed for Visual Studio 2013. It seems like a basic thing.

  • Thanks! Someone will take a look!

  • Alright thanks Maria. I really hope someone does look into it and can at least let me know what the deal is. It's quite frustrating debugging a large C++ mixed application the way it is.

  • Maria, there are no updates to my Microsoft Connect issue yet. Do you know if someone is looking at it?

  • @Adam Bruss

    The way customer bugs work, is that we have a first triage team that tries to repro and then passes them along to the feature teams. They couldn't repro your issue, but it is now assigned to someone on the C++ team to take a look at. They should keep you updated with the progress - ping them on the bug, as they should receive emails when it gets updated!

  • Major Kudos to the Microsoft team for all the additions to VS2013! I can't express how much I missed Intellisense, and the performance of "Go to Definition" makes this a usable feature again.  Having to use comparability mode for debugging is not a big deal in comparison and I look forward to having these new features for VC++ projects.

    Thanks!

  • I found that another place this is needed when attempting to watch a variable that's created using the Moq mocking framework.

Page 2 of 2 (25 items) 12