开发者

What is the .NET folder search hierarchy?

When .NET needs to load an 开发者_开发知识库assembly, what is the folder hierarchy that it uses to search for the assembly? I assume it starts with the GAC, and then local folder of the executing assembly? What is the complete hierarchy? I know the Windows search path (for unmanaged code) is something like local folder/System32 folder/search path/etc. and I am looking for something similar for .NET.


If you were looking for a description of the process rather than links to lengthy MSDN articles, this is a brief summary of the steps. You can find more details here.

Steps the runtime follows to resolve an assembly reference:

  1. Determines the correct assembly version by examining applicable configuration files.
  2. Checks whether the assembly name has been bound to before and, if so, uses the previously loaded assembly.
  3. Checks the GAC.
  4. Probes for the assembly by following these steps:

    a) If configuration and publisher policy do not affect the original reference and if the bind request was created using the Assembly.LoadFrom method, the runtime checks for location hints.

    b) If a codebase is found in the configuration files, the runtime checks only this location.

    c) Probes for the assembly using the heuristics described in the probing section. If the assembly is not found after probing, the runtime requests the Windows Installer to provide the assembly. This acts as an install-on-demand feature.


Here are a few articles from MSDN:

  • http://msdn.microsoft.com/en-us/library/yx7xezcf(v=VS.100).aspx
  • http://msdn.microsoft.com/en-us/library/15hyw9x3.aspx


Look at this article How the runtime locates assemblies.

It's actually not a linear path, and it depends on a lot (is the assembly loaded already, configuration files, ...) but the article is very clear.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜