Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.

Revit API Forum

Reply
Post 1 of 13
Accepted Solution

`Use managed compatibility mode` or `Enable native code debugging`?

262 Views, 12 Replies
02-10-2017 03:52 AM

Visual Studio 2015

 

I write .net-plugins for Autodesk Revit. Revit is unmanaged application. So, for successfully debugging I am to set into ON either for Use managed compatibility mode option or for Enable native code debugging option (or for both of them). Otherwise debugging cannot be launched.

The first of them is applied for all projects. The second of them is used for each project individually.

 

0.png

 

What the difference of these options? I don't understand what they do. What option it is more correct to use in my case?

 

Thank you.

Hans Passant answered to me. I marked by bould info which may be a reason why I am to use this option for Revit add-ins debugging:

 

You do not have to enable unmanaged debugging to debug your plugin. Breakpoints in your code will activate (turn from hollow to solid) when the host application loads your add-in. If you are not sure if this happened then have a look at the Debug > Windows > Modules window.

 

Enabling unmanaged debugging does not otherwise greatly affect the debugging session, it can however take quite a bit longer to get started and you may need to temporarily disable the symbol server to avoid getting annoyed at it.

 

The Tools > Options settings have rather poor names. Microsoft has been working on new debugging engines but was forced (or chose) to drop some features. "Use Managed Compatibility Mode" forces an older version of the managed debugger to be loaded, the one that was used in VS2010. It is required when you debug C++/CLI code. It can be also useful in VS2015, its managed debugging engine is very buggy. You'll miss out on some new debugging features like return value inspection and 64-bit edit+continue. You don't otherwise need it to debug your add-in.

 

Much the same story for "Use Native Compatibility Mode", it enables an older version of the unmanaged debugging engine, the one in VS2012 afaik. You'll miss out on the new Natvis visualizers. I have not yet found a compelling reason to need it, other than keep the old visualizers working.

 

Thanks to him.

Highlighted
Post 2 of 13

Re: `Use managed compatibility mode` or `Enable native code debugging`?

02-10-2017 05:33 AM in reply to: Andrey_Bushman

Hans Passant answered to me. I marked by bould info which may be a reason why I am to use this option for Revit add-ins debugging:

 

You do not have to enable unmanaged debugging to debug your plugin. Breakpoints in your code will activate (turn from hollow to solid) when the host application loads your add-in. If you are not sure if this happened then have a look at the Debug > Windows > Modules window.

 

Enabling unmanaged debugging does not otherwise greatly affect the debugging session, it can however take quite a bit longer to get started and you may need to temporarily disable the symbol server to avoid getting annoyed at it.

 

The Tools > Options settings have rather poor names. Microsoft has been working on new debugging engines but was forced (or chose) to drop some features. "Use Managed Compatibility Mode" forces an older version of the managed debugger to be loaded, the one that was used in VS2010. It is required when you debug C++/CLI code. It can be also useful in VS2015, its managed debugging engine is very buggy. You'll miss out on some new debugging features like return value inspection and 64-bit edit+continue. You don't otherwise need it to debug your add-in.

 

Much the same story for "Use Native Compatibility Mode", it enables an older version of the unmanaged debugging engine, the one in VS2012 afaik. You'll miss out on the new Natvis visualizers. I have not yet found a compelling reason to need it, other than keep the old visualizers working.

 

Thanks to him.

Post 3 of 13

Re: `Use managed compatibility mode` or `Enable native code debugging`?

02-10-2017 11:08 AM in reply to: Andrey_Bushman

I am not sure I understand. I think that one of these must be enabled, or debugging will not work at all. This makes it sound as if both are optional. That cannot be, can it?



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Post 4 of 13

Re: `Use managed compatibility mode` or `Enable native code debugging`?

02-10-2017 11:40 AM in reply to: jeremytammik

> I think that one of these must be enabled, or debugging will not work at all.

 

Yes, you are right.

 

> This makes it sound as if both are optional.

 

No, you are mistaken (in my opinion).

 

> That cannot be, can it?

 

Yes, you are right.

 

> You do not have to enable unmanaged debugging to debug your plugin.

> ...

> "Use Managed Compatibility Mode" forces an older version of the managed debugger to be loaded, the one that was used in VS2010. It is required when you debug C++/CLI code. It can be also useful in VS2015, its managed debugging engine is very buggy.

 

It means, that we are to use the Use Managed Compatibility Mode" option.

Post 5 of 13

Re: `Use managed compatibility mode` or `Enable native code debugging`?

02-10-2017 01:47 PM in reply to: Andrey_Bushman

Hm... But on my home computer I have other result: the debugging works only when both options are turned on! Here is video: https://www.youtube.com/watch?v=E8n-KjyQ-uw&feature=youtu.be

 

Post 6 of 13

Re: `Use managed compatibility mode` or `Enable native code debugging`?

02-10-2017 02:22 PM in reply to: Andrey_Bushman
I have both turned off and debugging works fine (if the Revit.exe.config fix is applied).

Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Post 7 of 13

Re: `Use managed compatibility mode` or `Enable native code debugging`?

02-10-2017 10:56 PM in reply to: matthew.taylor

Thank you Matt,

 

What version has your VS2015?

 

This is mine:

 vs-version.png

 

Post 8 of 13

Re: `Use managed compatibility mode` or `Enable native code debugging`?

02-10-2017 11:26 PM in reply to: Andrey_Bushman

On my home computer and on my office computer I have the same VS version: VS2015 Enterprise 14.0.25123.00 Update 2.

Post 9 of 13

Re: `Use managed compatibility mode` or `Enable native code debugging`?

02-11-2017 03:54 AM in reply to: Andrey_Bushman

It seems that the difference in behavior is caused by Revit versions... For example, for AutoCAD 2017 was released SP1 specially for compatibility with a debugger.

Post 10 of 13

Re: `Use managed compatibility mode` or `Enable native code debugging`?

02-11-2017 04:28 AM in reply to: Andrey_Bushman

After installation of VS2015 Update 3 on the home computer the debugging began to be launched successfully for such variant:

    "Use Managed Compatibility Mode" = ON
    "Enable native code debugging" = OFF.

Post 11 of 13

Re: `Use managed compatibility mode` or `Enable native code debugging`?

02-13-2017 01:07 AM in reply to: Andrey_Bushman

At the moment I'm on VS2013, fully updated. Obviously no edit and continue for x64.


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Post 12 of 13

Re: `Use managed compatibility mode` or `Enable native code debugging`?

02-14-2017 02:27 AM in reply to: matthew.taylor

Dear @matthew.taylor

 

What Revit.exe.config fix are you referring to, please?

 

Thank you!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Post 13 of 13

Re: `Use managed compatibility mode` or `Enable native code debugging`?

02-14-2017 03:59 AM in reply to: jeremytammik

Hi Jeremy,


Hmm. I'm talking about the one described here:

http://bimdev.blogspot.co.uk/2010/11/debugging-net-35-class-with-revit-2011.html

 

I can't remember exactly where I first saw it. Figured it was your blog, but it appears not!

 

I have just tried to debug a Revit 2011 (!!) macro using the fix and it doesn't appear to work. Can't get a breakpoint to hit. It used to be my go-to solution.

I've just tried to debug Revit 2017 (with no alterations to revit.exe.config), and it hits each breakpoint without issue.

 

I've attached my successful Revit 2017 / Visual Studio Pro 2013 (Update 5) settings, if anyone is interested.

 

Cheers,

 

-Matt

 

 

 

 


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post

Revit Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Revit helps you achieve greater speed, accuracy, and automation from concept to manufacturing.