When an Assembly.Load is not really Assembly.Load

This is an interesting discovery I find when I was investigating a regression.

The following code is really Assembly.LoadFrom

                    AssemblyName assemName = new AssemblyName();
                    assemName.CodeBase = pathToAssembly;
                    resultAssembly = Assembly.Load(assemName);

It is the same as

                   resultAssembly = Assembly.LoadFrom(PathToAssembly);

Assembly.Load(AssemblyName) will first attempt to use the assembly name (name,version,culture,publickeytoken) to find the assembly. If that fails, and AssemblyName has a codebase set, CLR loader will attempt an Assembly.LoadFrom with the codebase.

In our example, since the name is empty, loader will directly try Assembly.LoadFrom on the codebase.