Freigeben über


Error When EnvDTE Is Used with VSLangProj Assemblies

Visual Studio add-ins are deprecated in Visual Studio 2013. You should upgrade your add-ins to VSPackage extensions. For more information about upgrading, see FAQ: Converting Add-ins to VSPackage Extensions.

If you create a project that references one or more of the VSLangProj assemblies and the EnvDTE assembly, you can occasionally get the following error at runtime:

"Unhandled Exception: System.IO.FileNotFoundException: Error while loading file 'EnvDTE, Version=7.0.3300.0"

This error is due to a runtime type resolution conflict. That is, the version of EnvDTE that is included with Visual Studio 2005 is 8.0.xx, but the project's configuration reference is looking for an earlier version of this assembly, version 7.0.xx. To fix this problem, you must add a binding redirect for the newer version of EnvDTE to your project's configuration (.config) file. This will enable Visual Studio to load the newer version of EnvDTE and prevent the error from occuring.

To do this, add an "Application Configuration File" to your project and then replace its contents with the following:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-
        com:asm.v1" appliesTo="v2.0.50318">
            <dependentAssembly>
                <assemblyIdentity name="EnvDTE" publicKeyToken=
                "b03f5f7f11d50a3a"/>
                <bindingRedirect oldVersion="7.0.3300.0" 
                newVersion="8.0.0.0"/>
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>

This error occurs only if you are building an EXE, since DLL's do not have config files.

See Also

Tasks

How to: Add References to Automation Namespaces

Other Resources

Referencing Automation Assemblies and the DTE2 Object