Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can different versions of DLL be loaded in same application?

My application uses one version of library (a.dll), I am using another DLL(b.dll) which in-turn uses older version of the same library (a.dll) that i use. I am building the application by embedding a manifest file. The DLL i use is also using a embedded manifest file. I am having both the versions of the library in my WinSXS folder. My application is not able to load the appropriate versions of DLLs.

Will having a separate manifest file (not embedding into DLL) help resolving the problem? What is the work around?

like image 647
Sulla Avatar asked Dec 09 '10 09:12

Sulla


People also ask

How do I use two versions of the same DLL in the same project?

config. Under <runtime> , add a <codeBase> tag for each version of the DLL. This will resolve the runtime assembly loading conflict. That's it, now we can use both versions as we please.

Can you load the same DLL twice?

You can not load the same DLL multiple times into a single process (or not and have any effect). If you make the DLL a COM host and use COM objects then this will be automatically handled by each class instance.

Is DLL shared between processes?

DLLs will not be shared. If two processes use the same DLL each process has a own copy and the stored data of variabled declared in the DLL will not interfere the values of the dll of the other process. The only exception would be if you would create a shared data segment to change data across process boundaries.

Are all DLL files the same?

The file formats for DLLs are the same as for Windows EXE files – that is, Portable Executable (PE) for 32-bit and 64-bit Windows, and New Executable (NE) for 16-bit Windows. As with EXEs, DLLs can contain code, data, and resources, in any combination.


1 Answers

Your situation is exactly the situation WinSxS is supposed to solve. It should be working.

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

The shared assembly in WinSxS was installed with a configuration policy that automatically redirects requests for v1.0 to v1.1


Some clarifications are needed: App.exe and b.dll are implicitly linked against a.dll? Or do they load it via LoadLibrary.

If B.DLL loads A.DLL explicitly using LoadLibrary then you need to add ISOLATION_AWARE_ENABLED to your pre-processor definitions to ensure that 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 which was created by the EXE's manifest.

like image 200
Chris Becke Avatar answered Sep 22 '22 14:09

Chris Becke