how to locate dll in native c++ world / dotnet world?

总结:

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?

posted @ 2010-12-16 23:25  能巴  阅读(236)  评论(0编辑  收藏  举报