c++ - Can I get separate DLLs to resolve their imported DLLs separately? -


i've got dlls arranged this:

  • lib.dll - 3rd-party dll import library link to
  • plugin.dll - dll links lib.dll, plugin designed loaded host program loadlibrary
  • other\plugin.dll - plugin dll links lib.dll
  • other\lib.dll - otherplugin's copy of lib.dll

(these ordinary dlls exported functions - i'm not using com or anything.)

in test setup, if use loadlibrary load plugin.dll, , use loadlibrary load other\plugin.dll, seems both share same loaded copy of lib.dll. need other\plugin.dll load other\lib.dll - don't want libraries shared.

can this? (ideally without having recompile lib.dll.)

the technology allows called application isolation. way works having developer arrange dlls side side assemblies using manifest files.

read isolated applications on msdn official documentation.


alternatively, work without that, assuming are, in fact, loading "lib.dll" explicitly via loadlibrary.

first, note when dll calls loadlibrary, dlls own folder not searched. if check documentation loadlibrary on msdn see application executables folder preferred search location. first thing need call setdlldirectory before loading plugin.dll can find own copy of "lib.dll".

next - note loadlibrary search paths used when relative path passed.

so, if first fix dlldirectory , loadlibrary "plugin.dll" call loadlibrary, passing qualified path own copy of lib.dll, plugin.dll load own version using search path, , app load own version explicitly.


Comments