Skip to content

19.2 Win10遭遇"应用程序的并行配置不正确"

https://scz.617.cn/windows/202111171024.txt

Q:

从VS 2019/Win10 SDK中复制如下文件到A机

C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\

signtool.exe signtool.exe.manifest

A机未装VS 2019/Win10 SDK,在A机执行

Z:\Green\signtool\signtool.exe

报错

The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.

中文报错

应用程序无法启动,因为应用程序的并行配置不正确。有关详细信息,请参阅应用程 序事件日志,或使用命令行 sxstrace.exe 工具。

A: scz@nsfocus 2021-11-17 10:24

这个报错太缺德,实际原因是signtool.exe的依赖库未就位,但这里面有很多微妙之 处,下面一一解释。Process Monitor可以解决这类依赖库问题,此处略过。

有些解决方案忽悠你安装

Microsoft Visual C++ 20xx Redistributable Package

这就是为拍死苍蝇而引爆核弹。

就原始问题而言,在A机删除或重命名signtool.exe.manifest,一般signtool.exe就 可以正常使用了。之所以碰上依赖库问题,正是.manifest文件引起的。.manifest文 件本来是为了缓解"DLL地狱"现象而出场的技术,但有时候会坑你,比如原始问题所 处场景。

signtool.exe.manifest内容如下


<assemblyIdentity
    name=" "
    version="0.0.0.0"
/>

<dependency>
    <dependentAssembly>
        <assemblyIdentity
            name="Microsoft.Windows.Build.Signing.mssign32.dll"
            version="0.0.0.0"
        />
    </dependentAssembly>
</dependency>

<dependency>
    <dependentAssembly>
        <assemblyIdentity
            name="Microsoft.Windows.Build.Signing.wintrust.dll"
            version="0.0.0.0"
        />
    </dependentAssembly>
</dependency>

<dependency>
    <dependentAssembly>
        <assemblyIdentity
            name="Microsoft.Windows.Build.Appx.AppxSip.dll"
            version="0.0.0.0"
        />
    </dependentAssembly>
</dependency>

其中指明依赖库。若signtool.exe.manifest存在,启动signtool.exe 时不是简单的PE依赖关系,最终需要源自VS 2019/Win10 SDK的这些文件就位

Microsoft.Windows.Build.Appx.AppxPackaging.dll.manifest Microsoft.Windows.Build.Appx.AppxSip.dll.manifest Microsoft.Windows.Build.Signing.mssign32.dll.manifest Microsoft.Windows.Build.Appx.OpcServices.dll.manifest Microsoft.Windows.Build.Signing.wintrust.dll.manifest signtool.exe.manifest appxpackaging.dll appxsip.dll mssign32.dll // 动用.manifest的情况下,不能用system32中的 opcservices.dll wintrust.dll // 动用.manifest的情况下,不能用system32中的 wintrust.dll.ini signtool.exe

PE就位还在其次,system32下可能就有,只是版本不同。但那几个.manifest是一定 要就位的。.manifest技术是成熟技术,不科普,要点是,一旦主PE动用.manifest, 依赖库也得动用.manifest,此时对依赖库的版本检查非常严格,mssign32.dll、 wintrust.dll就不能用system32下的了。

删掉signtool.exe.manifest,signtool.exe可以直接用system32下的mssign32.dll、 wintrust.dll。

下次碰上前述缺德的报错,直接找.manifest,看其中的。若删除 .manifest不能解决问题,就根据.manifest复制依赖库的.manifest,仍不能解决时 继续复制依赖库本身。动用.manifest的情况下,用CFF Explorer之类的PE工具查看 依赖库意义不大,甚至会误导。

主PE有可能在资源中内嵌.manifest,而不是单独的.manifest文件,此时无法删除 .manifest,只好老老实实找匹配的依赖库及其.manifest。

A: scz@nsfocus 2021-11-17 11:55

前述报错提示中提到"event log"和sxstrace.exe,在此一并解释。先说事件查看器

eventvwr.msc Windows Logs Application Error SideBySide

打开具体的Error,直白地告诉你,根据.manifest,哪个依赖库未就位。事件查看器 提供的诊断信息可比前述报错强多了。

再简单介绍sxstrace.exe的使用方式。

在管理员级cmd中执行

$ SxsTrace Trace -logfile:signtool.etl

Tracing started. Trace will be saved to file signtool.etl. Press Enter to stop tracing...

在普通cmd中执行

$ Z:\Green\signtool\signtool.exe

The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.

回到管理员级cmd中回车,停止跟踪,执行

$ SxsTrace Parse -logfile:signtool.etl -outfile:signtool.txt

Parsing log file signtool.etl... Parsing finished! Output saved to file signtool.txt.

查看signtool.txt

================= Begin Activation Context Generation. Input Parameter: Flags = 0 ProcessorArchitecture = AMD64 CultureFallBacks = en-US;en;zh-CN;zh-Hans;zh ManifestPath = Z:\Green\signtool\signtool.exe.Manifest AssemblyDirectory = Z:\Green\signtool\ Application Config File =


INFO: Parsing Manifest File Z:\Green\signtool\signtool.exe.Manifest. INFO: Manifest Definition Identity is ,version="0.0.0.0". INFO: Reference: Microsoft.Windows.Build.Signing.mssign32.dll,version="0.0.0.0" INFO: Reference: Microsoft.Windows.Build.Signing.wintrust.dll,version="0.0.0.0" INFO: Reference: Microsoft.Windows.Build.Appx.AppxSip.dll,version="0.0.0.0" INFO: Resolving reference Microsoft.Windows.Build.Signing.mssign32.dll,version="0.0.0.0". INFO: Resolving reference for ProcessorArchitecture Microsoft.Windows.Build.Signing.mssign32.dll,version="0.0.0.0". INFO: Resolving reference for culture Neutral. INFO: Applying Binding Policy. INFO: No binding policy redirect found. INFO: Begin assembly probing. INFO: Did not find the assembly in WinSxS. INFO: Attempt to probe manifest at Z:\Green\signtool\Microsoft.Windows.Build.Signing.mssign32.dll.DLL. INFO: Attempt to probe manifest at Z:\Green\signtool\Microsoft.Windows.Build.Signing.mssign32.dll.MANIFEST. INFO: Attempt to probe manifest at Z:\Green\signtool\Microsoft.Windows.Build.Signing.mssign32.dll\Microsoft.Windows.Build.Signing.mssign32.dll.DLL. INFO: Attempt to probe manifest at Z:\Green\signtool\Microsoft.Windows.Build.Signing.mssign32.dll\Microsoft.Windows.Build.Signing.mssign32.dll.MANIFEST. INFO: Did not find manifest for culture Neutral. INFO: End assembly probing. ERROR: Cannot resolve reference Microsoft.Windows.Build.Signing.mssign32.dll,version="0.0.0.0". ERROR: Activation Context generation failed. End Activation Context Generation.

SxsTrace提供的信息有个毛用,直接查看.manifest更快。这种看似专业的工具鸡肋 得很。