Archive: Isolated components prevent DLL conflicts


Isolated components prevent DLL conflicts
Thought this might be of interest as it is not mentioned in the NSIS manual or the forum ...

from Microsoft knowledgebase http://msdn.microsoft.com/library/de...components.asp

Authors of installation packages can specify that the installer copy the shared files (commonly shared DLLs) of an application into that application's folder rather than to a shared location. This private set of files (DLLs) are then used only by the application. Isolating the application together with its shared components in this manner has the following advantages:

The application always uses the versions of the shared files with which it was deployed.
Installing the application does not overwrite other versions of the shared files by other applications.
Subsequent installations of other applications using different versions of the shared files cannot overwrite the files used by this application.
Because the current implementation of COM keeps a single full path in the registry for each CLSID/Context pair, it forces all applications to use the same version of a shared DLL. To enable an application to keep a private copy of a COM server, the system loader in Windows 98 and Windows 2000 checks for the presence of a .LOCAL file in the application's folder. If the system loader detects a .LOCAL file, it alters its search logic to prefer DLLs located in the same folder as the application.

When Windows Installer version 1.1 and later versions execute the IsolateComponents action they copy the files of the component (commonly a shared DLL) specified in the Component_Shared column of the IsolatedComponent table into the same folder as the component (commonly an .exe file) specified in the Component_Application column. The installer creates a file in this directory, zero bytes in length, having the short file name of the key file for Component_Application (typically the name is the same as the application's .exe) appended with .LOCAL. The installer uses the registration for the component in its shared location and does not write any registration information for the copy of the component in the private location. The IsolatedComponent action and table are not available with Windows Installer version 1.0.


Please create a Wiki page.


Does anyone have a code example for this? I'd be very interested to see how exactly this is done.


What I could gather from this, is that you need to create an empty file named app.exe.local and put all the COM DLL files in the same directory. You can create that file using FileOpen.

A quick search on my computer showed TortoiseCVS uses that. You can take a look at its installer script. It seems to do nothing more than create that file.


Code example
This is the interesting part of the script that I mailed to you, I can't tell if everything works as it should however, so no guarantees ! :p

...
Section "System" SEC03
SetOverwrite on
SetOutPath "$SYS_FOLDER"
; RdP: hele directory met DLL, OCX etc. kopieeren naar bijv. \Windows\system32
File /r "E:\CD\system\"
; RdP: LET OP: indien .exe en .dll's in een directory (isolated components),
; dan "Zwfina.local" bestand aanmaken en DLL's niet registreren !
StrCmp $SYS_FOLDER $INSTDIR 0 lblRegistreren
File "E:\CD\program\${PRODUCT_NAME}.local"
Return

lblRegistreren:
; RdP: registreer VB6 .dll's
; RegDLL $SYS_FOLDER\*.dll
:p :p