An ADN partner, once had a issue reported by their add-in user/customer in which they received an "External Tool Failure" dialog on launching a specific flavor of Revit 2012 with the add-in installed. The exception was of System.BadImageFormatException type. The confusing bit was that the same add-in developed by the partner used to work for the same version of Revit Architecture (RAC) which was installed previously, on the same system.
After careful investigations, it was clear that the reason for this unexpected behavior was the settings in the Revit.exe.config under the <startup useLegacyV2RuntimeActivationPolicy> tag. When the settings were as follows, there was no exception reported:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
</startup>
But when the <supportedRuntime> tag was removed from the Revit.exe.config file, launching of Revit 2012 threw the System.BadImageFormatException error:
<startup useLegacyV2RuntimeActivationPolicy="true">
</startup>
On further investigations, it was evident that setting the value of the useLegacyV2RuntimeActivationPolicy to .NET framework 2.0 (or not providing any value like has been mentioned above), throws the BadImageFormatException for any Revit plug-in targeted to work with Revit with target framework 4.0.
The RevitVSTAConfig.exe tool that is shipped with Revit 2012 helps in toggling between .NET 2 and .NET 4 by editing the xml in the config file. This toggle helps prepare Revit to work with VSTA (by changing the runtime framework to 2.0) and undo the change as well – when Revit needs to work with the installed add-ins which target .NET framework 4.0.
The following setting is the default setting in Revit.exe.config file:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>