Revit API 2012 natively targets to the .NET Framework 4 as we know, so we’d better target to the same .NET Framework runtime in the Revit addin projects for Revit 2012 too so as to utilize the power of the latest framework and the underlying CLR.
If the projects are created from scratch in Visual Studio 2010, the target Framework will be the version 4 by default; if some Visual Studio 2008 projects for Revit addins are just migrated to the Visual Studio 2010 and the .NET Framework are retargeted, an error like the following may come up:
“The type 'System.Windows.Markup.IUriContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.”
Adding the System.Xaml reference into the projects will get the issue resolved right away. Of course, the Revit API 2012 assemblies should replace the old ones and necessary code adjustments have to be done such as the Regeneration attribute and the RegenerationOption enumeration we talked before. Then the addin projects should be able to be debugged in the Visual Studio 2010 IDE for Revit 2012 products.
The opposite situation exists if we’d like to create Revit 2012 addins still using the Visual Studio 2008. If the right version of Revit API 2012 assemblies have been referenced in and external commands/applications have been properly created and registered, the addin assemblies should be able to be loaded and run by Revit 2012, but when they are trying to be debugged from inside the IDE of Visual Studio 2008, an error message like the following will show up:
“Microsoft Visual Studio
Error while trying to run project: Unable to start program ‘C:\Program Files\Autodesk\Revit Architecture 2012\Program\Revit.exe’.
The debugger’s protocol is incompatible with the debuggee.”
Here is the screenshot:
Is there a way to work around the issue?
We’re going to address it in the next post. Stay tuned!
The Revit Addin Wizard (RevitAddinWizard) will target to the .NET Framework 4 automatically in case Revit version 2012 is selected and the Visual Studio 2010 is used to create the Revit addin projects in C#, VB.NET or even Managed C++/CLI.
Recent Comments