Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

13 REPLIES 13
SOLVED
Reply
Message 1 of 14
Andrey_Bushman
21486 Views, 13 Replies

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

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.

13 REPLIES 13
Message 2 of 14

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.

Message 3 of 14

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

Message 4 of 14

> 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.

Message 5 of 14

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

 

Message 6 of 14

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?
Message 7 of 14

Thank you Matt,

 

What version has your VS2015?

 

This is mine:

 vs-version.png

 

Message 8 of 14

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

Message 9 of 14

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.

Message 10 of 14

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.

Message 11 of 14

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?
Message 12 of 14

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

Message 13 of 14

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?
Message 14 of 14

Using Visual Studio 2019 and Revit 2019, I can have both "Use Managed Compatibility Mode" and "Enable native code debugging" disabled without problems. 

 

But, if I want to debug in Revit 2018, I need to have Use Managed Compatibility Mode checked.  Otherwise Revit crashes on startup and I get the following in VS output window.

 

The program '[3272] Revit.exe' has exited with code 0 (0x0). 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community