The sequence of interactions between CLR loader and fusion during Assembly.Load

The following describes roughly the sequence of interactions between CLR loader and fusion during Assembly.Load() in .Net framework 2.0.

1. User calls Assembly.Load.

2. Loader pass the assembly reference to fusion.

3. Fusion checks to see if the assembly has already loaded. If it is, the assembly is returned.

4. If not, fusion probes the assembly as described in MSDN. If fusion cannot find the assembly, it returns a failure.

5. If fusion finds an assembly, it asks loader to crack the metadata of the assembly.

6. Loader maps the assembly, usually using file mapping, and cracks the metadata of the assembly. Loader also stores the file mapping in a process wide cache.

7. After fusion gets the metadata of the assembly, it does a ref-def matching. If the check fails, fusion returns error.

8. Otherwise, fusion puts the assembly in a cache, and returns the assembly to loader.

9. Loader does some additional checks. If the checks are good, Loader loads the assembly by calling LoadLibrary.

10. After LoadLibrary, Loader does one more check to make sure the assembly did not change between the original file mapping and LoadLibrary. If the file has changed, Loader throws ref/def mismatch FileLoadException.

11. If everything is good, Loader returns the assembly.