Loads an System.Reflection.Assembly given its System.Reflection.AssemblyName.
The loaded assembly.
This method should be used only to load an assembly into the current application domain. This method is provided as a convenience for interoperability callers who cannot call the static System.Reflection.Assembly.Load(string) method. To load assemblies into other application domains, use a method such as AppDomain.CreateInstanceAndUnwrap(string, string).
If a version of the requested assembly is already loaded, this method returns the loaded assembly, even if a different version is requested.
Supplying a partial assembly name for assemblyRef is not recommended. (A partial name omits one or more of culture, version, or public key token. For overloads that take a string instead of an System.Reflection.AssemblyName object, "MyAssembly, Version=1.0.0.0" is an example of a partial name and "MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=18ab3442da84b47" is an example of a full name.) Using partial names has a negative effect on performance. In addition, a partial assembly name can load an assembly from the global assembly cache only if there is an exact copy of the assembly in the application base directory (AppDomain.BaseDirectory or AppDomainSetup.ApplicationBase).
If the current AppDomain object represents application domain A, and the erload:System.AppDomain.Load method is called from application domain B, the assembly is loaded into both application domains. For example, the following code loads MyAssembly into the new application domain ChildDomain and also into the application domain where the code executes:
code reference: System.AppDomain.Load#1
The assembly is loaded into both domains because System.Reflection.Assembly does not derive from MarshalByRefObject, and therefore the return value of the erload:System.AppDomain.Load method cannot be marshaled. Instead, the common language runtime tries to load the assembly into the calling application domain. The assemblies that are loaded into the two application domains might be different if the path settings for the two application domains are different.
If both the System.Reflection.AssemblyName.Name property and the System.Reflection.AssemblyName.CodeBase property are set, the first attempt to load the assembly uses the display name (including version, culture, and so on, as returned by the System.Reflection.Assembly.FullName property). If the file is not found, the System.Reflection.AssemblyName.CodeBase property is used to search for the assembly. If the assembly is found using System.Reflection.AssemblyName.CodeBase, the display name is matched against the assembly. If the match fails, a System.IO.FileLoadException is thrown.