我已经为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)
最佳答案
根据错误消息,您的扩展依赖于Microsoft.VisualStudio.Shell.15.0(这是VS 2017程序集)。因此,它不包含在您的VS 2015中。
如果您希望扩展支持Visual Studio的多个版本,则需要让VSPackage仅使用来支持您对VSPackage进行编程并使其适应于其中的Visual Studio版本的,即您所支持的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。
关于visual-studio - Visual Studio 2015无法加载包,因为Microsoft.VisualStudio.Shell.15.0无法加载,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46054343/