Debugging Revit 2014 API with Visual Studio 2013

Debugging Revit 2014 API with Visual Studio 2013

trevor.taylor
Enthusiast Enthusiast
4,583 Views
13 Replies
Message 1 of 14

Debugging Revit 2014 API with Visual Studio 2013

trevor.taylor
Enthusiast
Enthusiast

Hello all,

 

I've just installed Visual Studio 2013, but can't get it to debug revit addins properly. I'm running VS as admin, .NET 4.0. Projects debug fine in VS 2012, but in VS 2013 the project will start and revit will load, but all of my modeling commands are disabled. I can switch views, open projects, etc., but I can't, for example, create a wall or run an addin.

 

My addins run fineApp runs fine outside the debugger, but when debugging the Revit ribbon looks like this with most modeling commands disabled:

 

Ribbon.png

 

Can anyone tell me how to fix this?

 

Thanks!

0 Likes
4,584 Views
13 Replies
Replies (13)
Message 2 of 14

Anonymous
Not applicable

Did you find a solution to this? I am having the same problem.

 

 

0 Likes
Message 3 of 14

jeremytammik
Autodesk
Autodesk

Hey guys,

 

Have you tried switching to managed compatibility mode?

 

http://blogs.msdn.com/b/visualstudioalm/archive/2013/10/16/switching-to-managed-compatibility-mode-i...

 

I have not tried myself, because I am still happily using Visual Studio 2010  🙂

 

Cheers,

 

Jeremy



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

0 Likes
Message 4 of 14

trevor.taylor
Enthusiast
Enthusiast

"...because I am still happily using Visual Studio 2010."

 

Jeremy, we know you want some of that edit-and-continue stuff... 😉

 

Compatibility mode causes 2013 debugger to do its duty, but alas, no edit-and-continue.

 

Thanks for the tip!

0 Likes
Message 5 of 14

Anonymous
Not applicable

Thanks Jeremy! This did the trick:

 

solution.JPG

Message 6 of 14

jeremytammik
Autodesk
Autodesk

Hey Brett,

 

Wow! Congratulations! Well done!

 

Can someone please confirm that this works?

 

Thank you for sharing!

 

Kudos from me!

 

Cheers,

 

Jeremy



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

0 Likes
Message 7 of 14

trevor.taylor
Enthusiast
Enthusiast

Update. I find that the disabled ribbon problem when debugging with Visual Studio 2013 does not manifest if I compile my code, run revit 2014 and then attach to process. Using this technique, I can have Managed Compatibility mode toggled off.

 

I should have tested this earlier.

 

1) Compile code

2) Configure your .addin file to load your debug DLL

3) Run Revit (confirm that your addin is loaded)

4) In VS 2013, choose DEBUG --> Attach to process

5) Choose Revit.exe

Message 8 of 14

jeremytammik
Autodesk
Autodesk

Brilliant! Thank you for sharing this important discovery! May I promote this to a post on The Building Coder, please? Thank you! Cheers, Jeremy



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

0 Likes
Message 9 of 14

trevor.taylor
Enthusiast
Enthusiast

Thanks! Of course, please post!

0 Likes
Message 10 of 14

jeremytammik
Autodesk
Autodesk

Great, thank you!

 

One more question, or a few...

 

Why in heaven's name are you doing this?

 

🙂

 

I mean, what is the advantage?

 

Does edit and continue work with Revit add-ins?

 

What are the exact steps for making use of that with a Revit add-in?

 

Are there any other significant advantages?

 

Thank you!

 

Cheers,

 

Jeremy



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

0 Likes
Message 11 of 14

trevor.taylor
Enthusiast
Enthusiast

"Why in heaven's name are you doing this?"

 

Well, by the time it occured to me it occured to me that edit-and-continue couldn't work with a DLL I had already installed VS 2013 and didn't want the additional overhead of also installing VS 2012. Therefore, on I pressed. I discovered the 'attach-to-process' trick when trying to get the beta Revit to debug on a remote computer (since it would crash when I attempted to start it directly.) Attach to Process worked, so I tried it on my Visual Studio 2013 computer with locally installed Revit. Lo and behold, it worked and the ribbon behaved.

 

"I mean, what is the advantage? " None, since it doesn't work! However, if you could use edit and continue it would be like the VBA / LISP days when you could write a problem as you debugged it when we used often to write throw-away code to fix problem in AutoCAD drawings. Code could be written and executed so quickly that it wasn't worth keeping the program since by the time it was needed again it was quicker to re-write it than to find it again. But I'm describing a problem somewhat unique to corporate developers where we often have to address a very specific, often unique occurence.

 

"Does edit and continue work with Revit add-ins?"

 

I wish it did. Maybe in heaven... 🙂

 

 

0 Likes
Message 12 of 14

jeremytammik
Autodesk
Autodesk

Hi Trevor,

 

It is live on the blog now:

 

http://thebuildingcoder.typepad.com/blog/2013/11/debugging-revit-2014-api-with-visual-studio-2013.ht...

 

Thank you!

Cheers,

Jeremy



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

0 Likes
Message 13 of 14

jeremytammik
Autodesk
Autodesk

Hi again,

 

Here is an update on this; edit and continue of a Revit 2014 add-in with Visual Studio 2013 may work partially after all, at least in non-graphical views:

 

http://thebuildingcoder.typepad.com/blog/2013/12/visual-studio-2013-may-partially-support-edit-and-c...

 

Could you check it out, please, and let us know how it goes?

 

Mille grazie!

 

Cheers,

 

Jeremy



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

0 Likes
Message 14 of 14

Anonymous
Not applicable

Jeremy, I can confirm that it fixes a lot more than just that. I'm now using Visual Studio Community Edition Update 4 as per your blog, and it also fixes the following issues: 

 

1) TaskDialog throwing an exception saying it had to be in the main thread. 

2) LoadFamily() not working - returning false (not throwing an exception). 

 

I am so glad I read this thread! 

 

A huge thanks to Brett for that setting. 

 

0 Likes