I've read that placing an empty file named <AppName>.exe.local
in the application directory will cause the application to look in that directory fi开发者_运维技巧rst for DLLs
and OCXs
so as to avoid issues with conflicting DLLs
and OCXs
found elsewhere on the system.
But doesn't the application first look in the application directory anyway? What effect does the .local
file actually have?
To be frank, I've never heard of the .local
scheme before, but a quick search brought up this article which quite explains it:
For an application foo.exe, if there is a file foo.exe.local exists, Windows will first look at foo.exe’s application directory, before start the regular dll search. To mitigate the COM problem, the redirection applies both to full path dll loading, as well as partial name loading.
It appears that the .local
file forces even absolute-path searches to the application directory first, whereas usually absolute paths are unchanged and only relative paths follow the DLL search order.
Applications can depend on a specific version of a shared DLL and start to fail if another application is installed with a newer or older version of the same DLL. There are two ways to ensure that your application uses the correct DLL: DLL redirection and side-by-side components. Developers and administrators should use DLL redirection for existing applications, because it does not require any changes to the application. If you are creating a new application or updating an application and want to isolate your application from potential problems, create a side-by-side component.
Ref.: Dynamic-Link Library Redirection
精彩评论