Share via


The order in which Assemblies are located by runtime!

Just came across this question, and did some research! This is the order.

  1. Configuration files
    1. Application Configuration File
    2. Publisher Policy File
    3. Machine Configuration File.
  2. Check is made to see if the same assembly is loaded previously by any any other application.
  3. Global Assembly Cache
  4. Locating through <codebase> or <probing> in configuration file.
    1. Probing with private path is done in following order,

Probing with the privatePath Attribute

In addition to the culture subdirectories and the subdirectories named for the referenced assembly, the runtime also probes directories specified using the privatePath attribute of the <probing> element. The directories specified using the privatePath attribute must be subdirectories of the application's root directory. The directories probed vary depending on whether culture information is included in the referenced assembly request.

The runtime stops probing the first time it finds an assembly that matches the simple assembly name referenced, whether it is a correct match or not. If it is a correct match, that assembly is used. If it is not a correct match, probing stops and binding fails.

If culture is included, the following directories are probed:

   [application base] / [binpath] / [culture] / [assembly name].dll

   [application base] / [binpath] / [culture] / [assembly name] / [assembly name].dll

If culture information is not included, the following directories are probed:

   [application base] / [binpath] / [assembly name].dll

   [application base] / [binpath] / [assembly name] / [assembly name].dll

Probing the Application Base and Culture Directories

The runtime always begins probing in the application's base, which can be either a URL or the application's root directory on a computer. If the referenced assembly is not found in the application base and no culture information is provided, the runtime searches any subdirectories with the assembly name. The directories probed include:

   [application base] / [assembly name].dll

   [application base] / [assembly name] / [assembly name].dll

If culture information is specified for the referenced assembly, only the following directories are probed:

   [application base] / [culture] / [assembly name].dll

   [application base] / [culture] / [assembly name] / [assembly name].dll

Apart from this, something I could find was, if we have chain of depend. we can load all second-level depend., from first dependency file location.

For example, if Assembly1 references Assembly2 and Assembly1 was downloaded from https://www.code.microsoft.com/utils, that location is considered to be a hint about where to find Assembly2.dll. The runtime then probes for the assembly in,

https://www.code.microsoft.com/utils/Assembly2.dll and https://www.code.microsoft.com/utils/Assembly2/Assembly2.dll.