I am working on a Windows application (EXE) that uses multiple DLLs. Development is in VCExpress 2005 (VC 8.0), using C only.
Some of these DLLs are plug-ins/add-ons/extensions that are dynamically loaded using LoadLibrary
according to a configuration file read by the EXE.
Importantly: the application must be portable (in the sense of able to run from a USB flash drive or similar without installation), and the plug-in DLLs may not be in the same folder as the application EXE (legacy reasons).
With MSVC6 this is straightforward: compile, link, distribute EXE and DLLs.
With MSVC8 the C Runtime Library (MSVCRT) is no longer distributed with the OS, so one cannot rely on it being installed. To satisfy the portability requirement I need to use a private assembly. All EXEs and DLLs have had their manifests embedded.
My problem: the plug-in DLLs loaded via LoadLibrary()
do not find the private assembly that is in the EXE's folder, so attempting to load them fails unless the Microsoft.VC80.CRT
assembly is installed in winSxS.
The catch: if the manifests are removed from the plug-in DLLs, everything works.
My questions:
In the problem case, Windows doesn't seem to be following either the Assembly searching sequence or the Dynamic link library search order. Specifically it is looking for the private assembly in the path from which the DLL was loaded, not from which the application (EXE) was loaded.
I have attempted to verify this by putting the assembly adjacent to the DLL, and changing the current directory (to rule out related to working directory cases), and get the expected behaviour. Can anyone else confirm that this is the normal behaviour when usingLoadLibrary
with SxS?Am I right in assuming that without a manifest, the DLL falls back to non-SxS load order which is finding
msvcr80.dll
(rather than the assembly manifestMicrosoft.VC80.CRT.manifest
) in the EXE's folder?If I am right about (1) and (2), what do I lose by just excluding the manifest from the DLL? Rephrased, why shouldn't I solve my problem by just excluding the manifest?