【问题标题】:Assembly recompilation and assembly load issue程序集重新编译和程序集加载问题
【发布时间】:2012-12-11 16:06:46
【问题描述】:

我有一个可执行文件 (Foo.exe) 和一个库 Bar.dll。两个二进制文件都是NOT 强名称签名的。 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.

【问题讨论】:

    标签: .net .net-assembly ilasm ildasm


    【解决方案1】:

    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 中的那个

    【讨论】:

      猜你喜欢
      • 2023-03-26
      • 1970-01-01
      • 1970-01-01
      • 2023-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-11
      • 2015-12-11
      相关资源
      最近更新 更多