Kashif
Kashif

Reputation: 31

Dll And Exe.local File in vb.net

My application uses a 3rd party dll. If I remove myapp.exe.local file from my application directory and some application that uses the same dll with different version which will be register or in system32 directory, will my application run successfully? Which dll will be used?

And which directory will get preference - local application directory or registered or system32?

Upvotes: 1

Views: 1091

Answers (1)

Hans Passant
Hans Passant

Reputation: 941970

The app.exe.local file solves a DLL Hell problem for COM servers. Which have a key in the registry that specifies the location of DLL. That key is found through a guid, the CLSID of the coclass. HKLM\Software\Classes\CLSID contains the guids.

A hard requirement for COM is that the guid must be changed when you make a breaking change in the code for the server. That's however often skipped, it causes pain because changing the guid also requires recompiling the app that uses the component. Or the change was meant as a bug fix, non-breaking, but causes a problem in another app nonetheless.

By using the app.exe.local file, you force COM to always load the DLL that's stored in the same folder as the EXE, ignoring the path specified in the registry. Thus allowing apps to have different versions of the DLL, even though the registry can specify only one. So if you delete that file, odds are good that you'll either immediately break the app or be subjected to DLL Hell when another app updates the DLL.

The MSDN article is here. Google cache of it is here, MSDN has been pretty borken lately.

Upvotes: 2

Related Questions