internal static Assembly Load(String assemblyString, Assembly caller) { Assembly assembly; int error; if (assemblyString == null) { throw new ArgumentNullException("assemblyString"); } if (assemblyString.Length >= 7 && String.Compare(assemblyString, 0, "file://", 0, 7, true) == 0) { if (assemblyString.Length >= 10 && assemblyString[7] == '/' && assemblyString[9] == ':') { // Specification of the form "file:///X:...". assemblyString = assemblyString.Substring(8); } else { // Some other type of file specification. assemblyString = assemblyString.Substring(7); } assembly = LoadFromFile(assemblyString, out error, caller); } else { #if !ECMA_COMPAT AssemblyName name = AssemblyName.Parse(assemblyString); assembly = LoadFromName(name.Name, out error, caller); #else if (assemblyString.IndexOf(",") == -1) { assembly = LoadFromName(assemblyString, out error, caller); } else { assembly = LoadFromName(assemblyString.Substring(0, assemblyString.IndexOf(",")), out error, caller); } #endif // !ECMA_COMPAT } if (error == LoadError_OK) { return(assembly); } else { ThrowLoadError(assemblyString, error); return(null); } }
private static Assembly LoadWithPartialName(String partialName, Assembly caller) { Assembly assembly; AssemblyName name; int error; if (partialName == null) { throw new ArgumentNullException("partialName"); } name = AssemblyName.Parse(partialName); assembly = LoadFromName(name.Name, out error, caller); if (error == LoadError_OK) { return(assembly); } else { return(null); } }
internal static Assembly LoadFrom(String assemblyFile, Assembly caller) { char [] pathChars = new char[] { Path.DirectorySeparatorChar, Path.VolumeSeparatorChar, Path.AltDirectorySeparatorChar }; if (assemblyFile == null) { throw new ArgumentNullException("assemblyFile"); } int error; Assembly assembly; if (assemblyFile.Length >= 7 && String.Compare(assemblyFile, 0, "file://", 0, 7, true) == 0) { if (assemblyFile.Length >= 10 && assemblyFile[7] == '/' && assemblyFile[9] == ':') { // Specification of the form "file:///X:...". assemblyFile = assemblyFile.Substring(8); } else { // Some other type of file specification. assemblyFile = assemblyFile.Substring(7); } } if (assemblyFile.EndsWith(".dll") || assemblyFile.EndsWith(".DLL") || (assemblyFile.IndexOfAny(pathChars) != -1)) { assembly = LoadFromFile(assemblyFile, out error, caller); } else { #if !ECMA_COMPAT AssemblyName name = AssemblyName.Parse(assemblyFile); assembly = LoadFromName(name.Name, out error, caller); #else if (assemblyFile.IndexOf(",") == -1) { assembly = LoadFromName(assemblyFile, out error, caller); } else { assembly = LoadFromName(assemblyFile.Substring(0, assemblyFile.IndexOf(",")), out error, caller); } #endif // !ECMA_COMPAT } if (error == LoadError_OK) { return(assembly); } else { ThrowLoadError(assemblyFile, error); return(null); } }