Вопрос

I have an executable (Foo.exe) and a library Bar.dll. Both binaries are NOT strong name signed. The Bar.dll library depends on the executable file and has it specified in its manifest in such manner:

<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>

I do a roundtrip from Foo.exe -> msil -> Foo.exe with ildasm and ilasm. Decompilation with ildasm generates a single .il file, .res file and multiple .resources files. I recompile the application in such manner:

ilasm Foo.il /resource=Foo.res

After recompilation the application works and can be launched. The problem now is that the library Bar.dll that depends on the executable fails to load it (the Foo.exe executable) after recompilation. This is what fusion log gives me:

   *** 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.

Now before the recompilation the file loads successfully and the only difference in the fusion log are last 4 lines:

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: Error extracting manifest import from file (hr = 0x8013101b)

Error code 8013101b is COR_E_NEWER_RUNTIME. In other words, the assembly needs a newer version of the CLR than the one that is actually loaded. There's a pretty simple explanation for that, you are probably using the wrong version of ilasm.exe. Version 4 instead of version 2.

Be sure to use C:\Windows\Microsoft.NET\Framework\v2.0.50727\ilasm.exe, not the one in v4.0.30319

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top