Saturday, November 6, 2010

Debugging a .NET 3.5 Class with Revit 2011 from Visual Studio 2010

Have you ever tried to build a Revit 2011 addin in Visual Studio 2010 only to discover that your debug will not work!!!??? This can be very frustrating but easily fixed if you follow the quick configuration steps illustrated in this post!!


You will need to make a couple minor configurations to both the Autodesk Revit 2011 configuration file and the Visual Studio 2010 development environment in order to successfully debug a Visual Studio 2010 application.

Since all projects built for Autodesk Revit 2011 must be compiled targeting the Microsoft .NET 3.5 Framework, you will first need to set your Visual Studio project to target the .NET Framework 3.5:



The Visual Studio 2010 default .NET Framework is 4.0 while the required .NET Framework for Autodesk Revit 2011 is 3.5. You will need to specify a target framework environment in the Revit 2011 executable configuration file so Visual Studio doesn’t try to debug in its default .NET Framework 4 mode.

Modify the Revit.exe.config file to support debug with Visual Studio 2010 by navigating to the Program directory beneath your Revit product's installation directory and open the XML formatted file named “Revit.exe.config” in an ASCII text editor such as Notepad.exe.


Add the following three lines highlighted in yellow just inside the closing tag of “configuration” to allow debug control with Visual Studio 2010:



That's it!... You can now debug a Revit 2011 addin from Visual Studio 2010

4 comments:

Unknown said...

a really helpful post!
thanx
puyan

blushift said...

any idea how this can be done when using 2010 express?

Don said...

It works the same for Express. You may need to manually enter a debug executable in your .csproj or .vbproj file if you're having other troubles (one of the big limitations of Express).

blushift said...

You need to create or modify the projectName.csproj.user file

http://through-the-interface.typepad.com/through_the_interface/2006/07/debugging_using.html

Post a Comment

Note: Only a member of this blog may post a comment.