.net – In what order are locations searched to load referenced DLLs


I know that the .NET framework looks for referenced DLLs in several locations

  • Global assembly cache (GAC)
  • Any private paths added to the AppDomain
  • The current directory of the executing assembly

What order are those locations searched? Is the search for a DLL ceased if a match is found or does it continue through all locations (and if so, how are conflicts resolved)?

Also, please confirm or deny those locations and provide any other locations I have failed to mention.

Best Solution

Assembly loading is a rather elaborate process which depends on lots of different factors like configuration files, publisher policies, appdomain settings, CLR hosts, partial or full assembly names, etc.

The simple version is that the GAC is first, then the private paths. %PATH% is never used.

It is best to use Assembly Binding Log Viewer (Fuslogvw.exe) to debug any assembly loading problems.

EDIT http://msdn.microsoft.com/en-us/library/aa720133.aspx explains the process in more detail.

Related Question