以下情景。我在 VS 2017 中创建了一个新的 VSIX 项目。我在那里插入了一个新的工具窗口。此外,我创建了一个类库。生成的结构如下:
我唯一改变的是
我向该类添加了两个属性,
ToolWindow1Package
以便在加载解决方案后立即加载它[ProvideAutoLoad(VSConstants.UICONTEXT.SolutionHasSingleProject_string)] [ProvideAutoLoad(VSConstants.UICONTEXT.SolutionHasMultipleProjects_string)]
Initialize
方法_protected override void Initialize() { ToolWindow1Command.Initialize(this); base.Initialize(); Class1 class1 = new Class1(); Console.WriteLine(class1); }
当我加载解决方案时,无法使用 ActivityLog 中的以下条目加载包
<entry>
<record>1396</record>
<time>2018/01/10 15:16:12.081</time>
<type>Error</type>
<source>VisualStudio</source>
<description>LegacySitePackage failed for package [ToolWindow1Package]Source: 'TestExtension' Description: Could not load file or assembly 'TestLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)
System.IO.FileLoadException: Could not load file or assembly 'TestLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)
File name: 'TestLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
 at TestExtension.ToolWindow1Package.Initialize()
 at Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsPackage.SetSite(IServiceProvider sp)

</description>
<guid>{673860A0-BAF8-46CB-BDFD-F758C4C6EE3C}</guid>
<hr>80131044</hr>
<errorinfo></errorinfo>
库的 dll 仍然在扩展 dll 的文件夹中:
我什至尝试将库作为资产添加到 .vsixmanifest 中而不改变情况。有谁知道这个问题和解决方法?