繁体   English   中英

程序集重新编译和程序集负载问题

[英]Assembly recompilation and assembly load issue

我有一个可执行文件(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.

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

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.

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM