Can I load different versions of a DLL into a single application?

My application uses one version of the library (a.dll), I use another DLL (b.dll), which in turn uses an older version of the same library (a.dll) that I use. I create an application by inserting a manifest file. In the DLL, I also use the built-in manifest file. I have both versions of the library in my WinSXS folder. My application cannot load the corresponding versions of the DLL.

Will a separate manifest file (rather than embedding in a DLL) help solve the problem? What job?

+6
source share
2 answers

Your situation is exactly the situation that WinSxS should solve. It should work.

Either: manifest files point to the same version, or one of the manifest files is not properly embedded, or

WinSxS co-assembly was installed with a configuration policy that automatically redirects requests for v1.0 to v1.1


Some clarification needed: App.exe and b.dll are implicitly related to a.dll? Or they load it through LoadLibrary.

If B.DLL loads A.DLL explicitly using LoadLibrary, then you need to add ISOLATION_AWARE_ENABLED to your definitions in front of the processor to make sure that the LoadLibrary calls made by B.DLL look in the correct activation context. Otherwise, they will be made in the context of the default activation context that was created by the EXE manifest.

+6
source

This will depend on what the duplicated DLLs do and whether their versions are compatible. (for example, both of them gain access to shared objects in memory? If so, there is a good chance that something will explode.)

It will also depend on how these two identical DLLs load. If this is something other than an explicit LoadLibrary with a full path, then this probably won't work. The following issues are discussed here: Determine the loaded path for the DLL

In general, this might work if you are lucky. The fact that it can go catastrophically wrong is a good reason to avoid the problem, if possible. (In the worst case scenario, you can place one of the modules in another process and proxy all calls to it. Ideally, you can simply use the same version of the DLL in both modules.)

0
source

All Articles