Why is FrameworkVersionMismatchException thrown? (Hamed Ahmadi)

  • Comments 2

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" />

</compatibleFrameworks>

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.

Leave a Comment
  • Please add 7 and 5 and type the answer here:
  • Post
  • I have created an Outlook 2010 addin using Visual studio 2010 and VSTO 4.0. targeting .NET fw 3.5. I am trying to customize explorer ribbon by addind a custom tab. When I launch outlook 2010, i get the following error in event viewer and the addin manager says: "There was a runtime error when loading the addin".

    Customization URI: file:///c:/documents and settings/eiuser200/my documents/visual studio 2010/Projects/OutlookAddIn1/OutlookAddIn1/bin/Debug/OutlookAddIn1.vsto

    Exception: <compatibleFrameworks xmlns="urn:schemas-microsoft-com:clickonce.v2">

     <framework targetVersion="3.5" profile="Client" supportedRuntime="2.0.50727" />

    </compatibleFrameworks>

    </compatibleFrameworks>

      ************** Exception Text **************

    Microsoft.VisualStudio.Tools.Applications.Deployment.FrameworkVersionMismatchException: <compatibleFrameworks xmlns="urn:schemas-microsoft-com:clickonce.v2">

     <framework targetVersion="3.5" profile="Client" supportedRuntime="2.0.50727" />

    </compatibleFrameworks>

      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(ClickOnceAddInDeploymentManager clickOnceAddInDeploymentManager, OfficeAddInDeploymentManager officeAddInDeploymentManager, Boolean showUIDuringDeployment)

      at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.CreateCustomizationDomainInternal(String solutionLocation, String manifestName, String documentName, Boolean showUIDuringDeployment, IntPtr hostServiceProvider, IntPtr& executor)

    Can I target 3.5 framework with VSTO 4.0 and still leverage the new Outlook 2010 platform features (Explorer ribbon,backstage view)?

    Thanks,

    Furqan

  • Yes, you can target 3.5 and still develop solutions for Office 2010. As I mentioned in the last paragraph of the post, this exception does not have anything to do with your customization not loading. you can set the VSTO_SUPPRESSDISPLAYALERTS to 0 and set the loadbehavior to 3 for you addin, and restart the Outlook to see the "real" problem. for more questions, please refer to VSTO forum: http://social.msdn.microsoft.com/Forums/en-US/vsto/threads.

    Hamed

Page 1 of 1 (2 items)

Why is FrameworkVersionMismatchException thrown? (Hamed Ahmadi)