Monday, June 29, 2009

How CLR Locates and binds assemblies

.NET loads the assemblies in a structured manner.CLR is responsible to locating and binding assemblies.

Step 1: Check for the referred assembly upon the name and version.

Step 2: Check in previous referred assembly

Step 3: check in GAC

Step 4: Code base or probing

Here the information can over ride the pervious version. Here I am explaining what is happening in each step.

Step 1: Check referred assembly name and version.

· Check in the application config after the manifest check.

· Check for publishers policy (when the shared/public assembly has new version).this can be managed by

· Check in machine config(manages all .NET files in the machine)

Step 2:check in previous referred assembly

If CLR uses the same assembly it will take this only. why it is not first step means ,to examine the which version is required.

Step 3: Check in GAC (global assembly cache)

If the assembly is not found in the first two steps it should be a strong name, so it goes to GAC.

Step 4: code base or probing

This inform to CLR which version is required.

Code base: codebase is the tag in the application config .CLR checks the defined location only. if the assembly is not there probing has terminated.

Probing : if the no codebase tag is config.CLR starts probing

Subdirectories: search the application sub directories.CLR terminates probing as soon as the assembly is found.

if u have dought mail me