Type Summary
public class Assembly : IEvidenceFactory, ICustomAttributeProvider,
ISerializable
{
// Properties
MS CF public virtual string CodeBase { get; }
MS CF public virtual MethodInfo EntryPoint { get; }
MS CF public virtual string EscapedCodeBase { get; }
MS CF public virtual Evidence Evidence { get; }
public virtual string FullName { get; }
MS CF public bool GlobalAssemblyCache { get; }
MS CF 1.1 public virtual string ImageRuntimeVersion { get; }
MS CF public virtual string Location { get; }
// Methods
public object CreateInstance(string typeName);
MS CF public object CreateInstance(string typeName, bool ignoreCase);
MS CF public object CreateInstance(string typeName, bool ignoreCase,
BindingFlags bindingAttr, Binder binder, object[] args,
CultureInfo culture, object[] activationAttributes);
MS CF public static string CreateQualifiedName(string assemblyName,
string typeName);
MS CF public static Assembly GetAssembly(Type type);
MS public static Assembly GetCallingAssembly();
MS CF public virtual object[] GetCustomAttributes(bool inherit);
MS CF public virtual object[] GetCustomAttributes(Type attributeType,
bool inherit);
MS CF public static Assembly GetEntryAssembly();
MS public static Assembly GetExecutingAssembly();
MS CF public virtual Type[] GetExportedTypes();
MS CF public virtual FileStream GetFile(string name);
MS CF public virtual FileStream[] GetFiles();
MS CF public virtual FileStream[] GetFiles(bool getResourceModules);
MS CF public Module[] GetLoadedModules();
MS CF public Module[] GetLoadedModules(bool getResourceModules);
MS CF public virtual ManifestResourceInfo GetManifestResourceInfo(
string resourceName);
MS public virtual string[] GetManifestResourceNames();
MS public virtual Stream GetManifestResourceStream(string name);
MS public virtual Stream GetManifestResourceStream(Type type,
string name);
MS CF public Module GetModule(string name);
MS public Module[] GetModules();
MS CF public Module[] GetModules(bool getResourceModules);
MS public virtual AssemblyName GetName();
MS public virtual AssemblyName GetName(bool copiedName);
MS CF public virtual void GetObjectData(SerializationInfo info,
StreamingContext context);
MS CF public AssemblyName[] GetReferencedAssemblies();
MS public Assembly GetSatelliteAssembly(CultureInfo culture);
MS public Assembly GetSatelliteAssembly(CultureInfo culture,
Version version);
public virtual Type GetType(string name);
MS public virtual Type GetType(string name, bool throwOnError);
MS CF public Type GetType(string name, bool throwOnError, bool ignoreCase);
public virtual Type[] GetTypes();
MS CF public virtual bool IsDefined(Type attributeType, bool inherit);
MS public static Assembly Load(AssemblyName assemblyRef);
MS CF public static Assembly Load(AssemblyName assemblyRef,
Evidence assemblySecurity);
MS CF public static Assembly Load(byte[] rawAssembly);
MS CF public static Assembly Load(byte[] rawAssembly,
byte[] rawSymbolStore);
MS CF public static Assembly Load(byte[] rawAssembly, byte[] rawSymbolStore,
Evidence securityEvidence);
public static Assembly Load(string assemblyString);
MS CF public static Assembly Load(string assemblyString,
Evidence assemblySecurity);
MS CF 1.1 public static Assembly LoadFile(string path);
MS CF 1.1 public static Assembly LoadFile(string path,
Evidence securityEvidence);
MS public static Assembly LoadFrom(string assemblyFile);
MS CF public static Assembly LoadFrom(string assemblyFile,
Evidence securityEvidence);
MS CF 1.1 public static Assembly LoadFrom(string assemblyFile,
Evidence securityEvidence, byte[] hashValue,
AssemblyHashAlgorithm hashAlgorithm);
MS CF public Module LoadModule(string moduleName, byte[] rawModule);
MS CF public Module LoadModule(string moduleName, byte[] rawModule,
byte[] rawSymbolStore);
MS CF public static Assembly LoadWithPartialName(string partialName);
MS CF public static Assembly LoadWithPartialName(string partialName,
Evidence securityEvidence);
public override string ToString();
// Events
MS CF public event ModuleResolveEventHandler ModuleResolve;
}
|
SC
Calling Load(AssemblyName) is not necessarily the same as calling Load(String). If the AssemblyName.CodeBase is not set, then they do the same thing. So, if you've set the AssemblyName.Name, CultureInfo, public key token/public key and/or Version properties, it would be the same as if you had specified those properties in a String (as a display name) and passed that to Load(String).
However, if the AssemblyName.CodeBase is set, but the AssemblyName.Name is not, then it's the same as calling Assembly.LoadFrom() on that AssemblyName. CodeBase. When both the AssemblyName.CodeBase and the AssemblyName. Name are set, then the bind is tried with all the given binding information, except the AssemblyName.CodeBase (so, again, it's just like calling Load(String)). If that succeeds, we're done. But, if that fails, then the bind is tried again with just the AssemblyName.CodeBase (just like LoadFrom()). If it fails again, then of course the whole bind fails. But, if it succeeds, then we verify that the binding properties in the AssemblyName match the found assembly. If they don't match, a FileLoadException will be thrown for HResult FUSION_E_REF_DEF_MISMATCH.
So, setting both the AssemblyName.CodeBase and the AssemblyName.Name is useful for when you want to both load an assembly at a given path into the LoadFrom context, and verify that it has the public key token, and so forth, that you expect. Of course, as described above (and due to binding context rules), keep in mind that just because you call Load(AssemblyName) with a CodeBase does not mean that it will be loaded from that path. |
|