2

我有一个可执行文件 (Foo.exe) 和一个库 Bar.dll。两个二进制文件都没有强名称签名。Bar.dll 库依赖于可执行文件,并以如下方式在其清单中指定:

<dependency>
    <dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="Foo.exe" size="334336">
      <assemblyIdentity name="Foo" version="1.2.3.4" language="neutral" processorArchitecture="msil" />
    </dependentAssembly>
</dependency>

我使用 ildasm 和 ilasm 从 Foo.exe -> msil -> Foo.exe 进行往返。使用 ildasm 进行反编译会生成单个 .il 文件、.res 文件和多个 .resources 文件。我以这种方式重新编译应用程序:

ilasm Foo.il /resource=Foo.res

重新编译后,应用程序工作并可以启动。现在的问题是依赖于可执行文件的库 Bar.dll 在重新编译后无法加载它(Foo.exe 可执行文件)。这是融合日志给我的:

   *** Assembly Binder Log Entry  (11/12/2012 @ 5:00:38 PM) ***

The operation failed.
Bind result: hr = 0x8013101b. No description available.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable  C:\Program Files (x86)\SomeApplication\Something.EXE
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = Bartek-W7\Bartek
LOG: DisplayName = Bar, Version=1.2.3.4, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/FooBar
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : Bar, Version=1.2.3.4, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Application configurtion file not found.
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Program Files (x86)/FooBar/Foo.dll
LOG: Attempting download of new URL file:///C:/Program Files (x86)/FooBar/Foo/Foo.dll
LOG: Attempting download of new URL file:///C:/Program Files (x86)/FooBar/Foo.exe
LOG: Assembly download was successful. Attempting setup of file: C:/Program Files (x86)/FooBar/Foo.exe
LOG: Entering download cache setup phase.
ERR: Error extracting manifest import from file (hr = 0x8013101b).
ERR: Setup failed with hr = 0x8013101b.
ERR: Failed to complete setup of assembly (hr = 0x8013101b). Probing terminated.

现在在重新编译之前,文件加载成功,融合日志中的唯一区别是最后 4 行:

LOG: set name: Foo, Version=1.2.3.4, Culture=neutral, PublicKeyToken=null
WARNING: found a duplicate set during cache setup
LOG: Bind successful.
LOG: Bind is in default load context.
4

1 回答 1

4

ERR:从文件中提取清单导入时出错(hr = 0x8013101b)

错误代码 8013101b 是 COR_E_NEWER_RUNTIME。换句话说,程序集需要比实际加载的版本更新的 CLR 版本。对此有一个非常简单的解释,您可能使用了错误版本的 ilasm.exe。版本 4 而不是版本 2。

请务必使用 C:\Windows\Microsoft.NET\Framework\v2.0.50727\ilasm.exe,而不是 v4.0.30319 中的那个

于 2012-12-11T19:07:55.390 回答