Debugging with Visual Studio 2010 and RvtSamples

Rod Howarth just published a description of a problem

debugging a Revit 2011 add-in with Visual Studio 2010
.
He found a related thread on the Microsoft Connect Visual Studio discussion forum describing the

same issue with Revit 2010
and
presenting a solution for it:

The issue that you are encountering is that Visual Studio 2010 is launching Revit under the default debugger (v4.0) but since you are building a project against the 2.0 framework (3.5 runs on the CLR 2.0) in order to correctly debug your Revit plugin, Visual Studio must launch Revit under the 2.0 debugger, not the 4.0.

You can either launch Revit and manually attach to the Revit process with your Revit plugin open (the debugger will automatically attach with the correct engine once the process has already started), or you can add a <supportedRuntime> attribute to the <startup> section of the Revit.exe.config file that will allow Visual Studio to determine which debugger should be attached:

As Rod says, the workaround is to edit your Revit.exe.config file which is located in the same directory as Revit.exe and add the following just before the </configuration> part of it:


<startup>
<supportedRuntime version="v2.0.50727" />
</startup>

For more details, please refer to

Rod’s post
.

RvtSamples.txt Update

In a separate thread, Rod also mentioned a problem loading the version of RvtSamples.txt included with the Revit 2011 SDK.
This is the text file read by the

RvtSamples

SDK sample application
(for 2010)
to load all the other Revit SDK sample commands as well as potentially process

include files
to
load an additional set of own personal commands.
I ran into the same issues Rod describes, so I thought it worthwhile to publish
my current version of RvtSamples.txt
for Revit 2011 to save others the bother of having to explore what fixes need to be made.


Comments

2 responses to “Debugging with Visual Studio 2010 and RvtSamples”

  1. Cosmas Avatar
    Cosmas

    I have followed the above instructions to use Visual Studio 2010 with Revit, but my Breakoints in Visual Basic do not work. The Execute function in Visual Basic 2010 runs, opening Revit but it does not stop at the break points.
    Any ideas why?
    I am using .NET Framework3.5

  2. Cosmas Avatar
    Cosmas

    I solved the problem.
    My revit.exe.config file was not edited properly.
    It now works!

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading