Visual Studio 2015无法加载包,因为Microsoft.VisualStudio.Shell.15.0无法加载

时间:2017-09-05 11:52:39

标签: visual-studio visual-studio-extensions

我为Visual Studio 2015和2017构建了一个Visual Studio扩展。我在2017年开发了它,2017年一切都很好。

当我在VS 2015上安装它时,我收到一条错误消息,说它无法加载我的包。在visual studio ActivityLog.xml文件中,我看到以下错误。

如何启用VS 2015和2017来运行扩展程序?

CreateInstance failed for package [MainWindowPackage]
Source: 'mscorlib' 
Description: Could not load file or assembly 'Microsoft.VisualStudio.Shell.15.0, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. 

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.Shell.15.0, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. 

File name: 'Microsoft.VisualStudio.Shell.15.0, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type) at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) at System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo) at System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName) 

2 个答案:

答案 0 :(得分:4)

根据错误消息,您的扩展依赖于Microsoft.VisualStudio.Shell.15.0,这是一个VS 2017程序集。所以它不包含在你的VS 2015中。

如果您希望扩展程序支持多个版本的Visual Studio,则需要让VSPackage使用仅支持您支持的最早版本的Visual Studio 的功能并对VSPackage进行编程以适应运行它的Visual Studio版本。您可以阅读此文档:https://docs.microsoft.com/en-us/visualstudio/extensibility/choosing-between-shared-and-versioned-vspackages

您还可以参考Supporting Multiple Versions of Visual Studio

的文档

自定义安装路径为" C:\ Users \ UserName \ AppData \ Local \ Microsoft \ VisualStudio \ 14.0 \ Extensions \"。请检查您的扩展路径以确保已安装Microsoft.VisualStudio.Shell.15.0。

答案 1 :(得分:2)

您应该在扩展程序中引用Microsoft.VisualStudio.Shell。 14 .0和VS 2015中的其他程序集,以支持VS 2015/2017。