'Loading DLLs with manifest for dependencies of dependencies

My situation is:

  • A.dll depends on B.dll and C.dll
  • B.dll depends on C.dll
  • B.dll and C.dll are in a subfolder below the folder containing A.dll

B.dll and C.dll are inside an assembly (BCAssembly) with the following manifest:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <assemblyIdentity type="win32" name="AssemblyBC" version="1.0.0.0"/>
    <file name="B.dll"/>
    <file name="C.dll"/>
</assembly>

A.dll depends on AssemblyBC via its manifest, defined in A.dll's code:

#pragma comment(linker, "/manifestdependency:\"name='AssemblyBC' version='1.0.0.0' type='win32'\"")

When I load A.dll, I get error code 126 ("Specified module could not be found"). I have confirmed via Process Monitor that A.dll uses the manifest to successfully find B.dll and C.dll, but B.dll cannot find C.dll. I tried adding a B.dll.manifest specifying a dependency on AssemblyBC, but this had no effect, perhaps because B.dll is inside AssemblyBC. How can I use manifests to make B.dll find C.dll?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source