The “Microsoft.VisualStudio.Tools.Applications.Deployment.FrameworkVersionMismatchException” is thrown due to the specific implementation of how VSTO 2010 runtime loads the appropriate CLR to install a VSTO customization.
This exception is thrown when both .NET Framework 3.5 (CLR 2.0) and .NET Framework 4 (CLR 4) are installed on a machine and a VSTO customization which targets .NET Framework 4 is installed. The exception happens only when the customization is installed and has no impact on the successful installation and loading of the customization despite the fact that you can see an error logged in the event log, like this:
Microsoft.VisualStudio.Tools.Applications.Deployment.FrameworkVersionMismatchException: <compatibleFrameworks xmlns=”urn:schemas-microsoft-com:clickonce.v2″>
<framework targetVersion=”4.0″ profile=”Client” supportedRuntime=”4.0.30319″ />
<framework targetVersion=”4.0″ profile=”Full” supportedRuntime=”4.0.30319″ />
at Microsoft.VisualStudio.Tools.Office.Runtime.SolutionInstaller.Install(ClickOnceAddInDeploymentManager clickOnceAddInDeploymentManager, OfficeAddInDeploymentManager officeDeploymentManager, AddInInformation& info) at Microsoft.VisualStudio.Tools.Office.Runtime.SolutionInstaller.ProcessInstallerOperation(ClickOnceAddInDeploymentManager clickOnceAddInDeploymentManager, OfficeAddInDeploymentManager officeAddInDeploymentManager, AddInInformation& info) at Microsoft.VisualStudio.Tools.Office.Runtime.SolutionInstaller.ProcessInstallerOperation(Boolean uninstall, Boolean silent, Uri manifest, Int32& errorCode, String& errorMessage)
To install a VSTO customization, the native piece of VSTO runtime loads the CLR and lets the managed runtime parse the deployment manifest and install the customization. The target .NET Framework is specified in the deployment manifest (<CompatibleFrameworks> element). Therefore, when loading the CLR, the native VSTO runtime does not know which version of the .NET Framework the customization targets. Before CLR 4, CLR 2.0 was always loaded. Now that VSTO supports multi-targeting, we needed a mechanism to select the correct version of CLR to host.
At a high level, the runtime first attempts to load CLR 2.0 since we anticipated that the majority of developers target .NET Framework 3.5. Once CLR 2.0 is loaded, the managed runtime downloads and parses the deployment manifest. At this moment, if it is found out that the customization targets .NET Framework 4, “FrameworkVersionMismatchException” is thrown by the managed runtime and the compatible Framework is passed along. The native runtime catches the exception and loads CLR 4.
In summary, this exception does not indicate any error and is not the reason why a VSTO customization is not installed or loaded properly. Please follow the instructions in Debugging in Application-Level Projects and Debugging in Document-Level Projects to troubleshoot a VSTO customization. Should you have further questions about your customization, please visit VSTO forum.