【问题标题】:Assembly identity names in SxS manifestsSxS 清单中的程序集标识名称
【发布时间】:2018-02-27 18:14:01
【问题描述】:

我有两个关于激活上下文 API 和 SxS 清单的问题。它们看起来很简单,但我仍然无法为它们找到任何好的答案。

我有两个文件名为 foo.dll 和 bar.dll 的 dll 库,它们都带有嵌入式清单,foo 依赖于 bar。有没有办法为这两个分配文件名以外的 assemblyIdentity 名称?例如,如果我希望 bar.dll 的程序集标识为 CompanyName.Subsection.bar ?如果我像这样更改它的身份 - 我在尝试加载 foo.dll "Dependent Assembly CompanyName.Subsection.bar,type="win32",version="0.1.2.3" could not be found" 时出错。当然,如果我将名称程序集标识指定为文件名 (<assemblyIdentity name="bar"),一切正常,但有没有办法使用这些带点的名称?

foo.dll

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity name="foo" version="0.1.2.3" type="win32"/>
<dependency>
    <dependentAssembly>
        <assemblyIdentity name="CompanyName.Subsection.bar" version="0.1.2.3" type="win32" />
    </dependentAssembly>
</dependency>
<file name="foo.dll">
</file>
</assembly> 

bar.dll

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity name="CompanyName.Subsection.bar" version="0.1.2.3" type="win32"/>
<file name="bar.dll">
</file>
</assembly> 

【问题讨论】:

    标签: c++ dll winsxs sxs activation-context-api


    【解决方案1】:

    如果不是嵌入 bar.dll 的清单,而是将它与 dll 本身放在一个单独的文件夹中,则可以做到这一点。即:

    foo.dll
    CompanyName.Subsection.bar/
    ├── bar.dll
    └── CompanyName.Subsection.bar.manifest
    

    您仍然需要将第一个清单嵌入到 foo.dll 中。我相信您可以从该清单中删除以下 sn-p,因为它是嵌入式清单,因此不需要指定哪些 dll 属于程序集:

    <file name="foo.dll">
    </file>
    

    bar.dll 的清单很好,但请务必按​​照assemblyIdentity 元素中指定的方式命名文件夹清单文件(参见上面的示例文件夹结构)。

    另请注意,您可以使用sxstrace 命令行工具诊断与加载 SxS 程序集相关的问题。分步说明:

    1. 从 Visual Studio 命令行运行 sxstrace trace -logfile:mytrace.etl。在您按 ENTER 之前,该命令不会返回。但是,暂时不要按 ENTER。
    2. 启动加载 foo.dll 的应用程序以重现您的问题
    3. 然后在命令行窗口中按 ENTER 停止 sxstrace
    4. 您现在有一个文件 mytrace.etl,它不是人类可读的。通过运行sxstrace parse -logfile:mytrace.etl -outfile:mytrace.txt 将其转换为可读格式。你会得到一个 mytrace.txt 文件,它显示了当你加载 foo.dll 时会发生什么,以及它在哪里无法解决它的一些依赖关系。

    【讨论】:

      猜你喜欢
      • 2023-03-18
      • 1970-01-01
      • 1970-01-01
      • 2014-05-09
      • 1970-01-01
      • 1970-01-01
      • 2021-12-08
      • 2019-10-30
      • 1970-01-01
      相关资源
      最近更新 更多