As mentioned before, Revit 2012 is built with the .NET Framework Runtime 4.0 and forces its addins to use the same version as indicated in its configuration file, revit.exe.config:
<configuration>
…
…
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
</configuration>
However, if the supportedRuntime line in the file has been commented out and we are trying to load a Revit addin built really with the version 4.0 of .NET Framework Runtime, what will happen?
Here are the descriptive messages:
“External Tools – External Tool Failure
Revit cannot run the external application. Contact the provider for assistance. Information they provided to Revit about their identity:.
System.BadImageFormatException
Could not load file or assembly
‘file:///c:\temp\RevitAddinCS1.dll’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.”
Here is a screenshot of this kind of errors:
The error message is not so descriptive actually but we can still sense something from the last sentence.
So adding the supportedRuntime version 4.0 back into the revit.exe.config file resolves the problem right away. It is unlikely that the problem will happen if you never touch on the revit.exe.config file but just in case this post may be a good reminder.
All in all, checking the .NET Framework Runtime version that your Revit addins linked with and the .NET Framework Runtime version that the host Revit really supports and make sure they match with each other is a critical matter.
If readers use both Visual Studio 2008 and Visual Studio 2010 and switch between them back and forth and/or use the Revit Addin Wizard (RevitAddinWizard) in Visual Studio 2008 to create addins for Revit 2012, please keep in mind these stuffs about the .NET Framework target in the addins and the supportedRuntime in the revit.exe.config file.
Recent Comments