gpt4 book ai didi

c# - VsPackage中类库的使用方法

转载 作者:行者123 更新时间:2023-11-30 21:36:27 25 4
gpt4 key购买 nike

以下场景。我在 VS 2017 中创建了一个新的 VSIX 项目。我在那里插入了一个新的工具窗口。此外,我还创建了一个类库。生成的结构如下: Project Structure

我唯一改变的是

  • 我向 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);
    }

当我加载解决方案时,程序包无法加载,事件日志中有以下条目

<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: &apos;TestExtension&apos; Description: Could not load file or assembly &apos;TestLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&apos; or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)&#x000D;&#x000A;System.IO.FileLoadException: Could not load file or assembly &apos;TestLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&apos; or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)&#x000D;&#x000A;File name: &apos;TestLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&apos;&#x000D;&#x000A; at TestExtension.ToolWindow1Package.Initialize()&#x000D;&#x000A; at Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsPackage.SetSite(IServiceProvider sp)&#x000D;&#x000A;&#x000D;&#x000A;</description>
<guid>{673860A0-BAF8-46CB-BDFD-F758C4C6EE3C}</guid>
<hr>80131044</hr>
<errorinfo></errorinfo>

库的dll仍然在扩展dll的文件夹中:

Files

我什至尝试将库作为 Assets 添加到 .vsixmanifest 中,但情况没有发生变化。有谁知道这个问题和解决方法?

最佳答案

如错误消息所述,您必须通过向项目添加 key.snk 文件对 TestLibrary dll/项目进行强签名。 (项目属性,签名)

关于c# - VsPackage中类库的使用方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48191001/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com