我已经为 Visual Studio 2015 和 2017 构建了一个 Visual Studio 扩展。我已经在 2017 年开发了它,并且在 2017 年一切正常。
当我在 VS 2015 上安装它时,我收到一条错误消息,说它无法加载我的包。在视觉工作室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 使用 仅 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。
关于visual-studio - Visual Studio 2015 无法加载包,因为 Microsoft.VisualStudio.Shell.15.0 无法加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46054343/