總結:
1. 對於native c++ world來說,Dynamic-Link Library Search Order 說的很清楚了。就是還有一個疑問:如果在任意目錄建立一新folder,把一個application需要的plugin之類的dll及dependency dlls都放在裡面,在load這個plugin需要的dependency dlls時 (If a DLL with dependencies is loaded by specifying a full path, the system searches for the DLL's dependent DLLs as if they were loaded with just their module names.)這個新的folder會被search到嗎?
2. 對於dotnet world,首先理解有兩個application級的檔案:app.exe.manifest, app.exe.config。 然後,關於runtime CLR如何locate assembly,這篇How the Runtime Locates Assemblies 是全面的介紹。The simple version is that the GAC is searched firstly, and then the app path tree. %PATH% is never used. 相關基礎知識:
1)In dotnet world, A private assembly is stored in the application’s directory and used by a single application. A share assembly can be used by multiple applications and is stored in the Global assembly cache, a repository of assemblies maintained by the .Net Framework.
2)GAC 和sidebyside的區別,本blog裡有詳細介紹。
3)如果你確實需要把一個app的private assembly(一定程度上算,但絕對算不是放在GAC裡的資格)搬出app path來放,MS還提供了一套機制來協助你定位assembly成功:AssemblyResolver。具體介紹,參見本blog AssemblyResolver。
4)use Assembly Binding Log Viewer (Fuslogvw.exe) to debug any assembly loading problems.
參考: In what order are locations searched to load referenced DLLs?