以下方案。我在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中添加库作为资产而不改变情况。有谁知道这个问题和解决方法?
答案 0 :(得分:3)
您必须通过向项目添加key.snk文件来强烈签署TestLibrary dll /项目,如错误消息所示。 (项目属性,签名)