private Assembly LoadFile(string path) { string ex = null; try { using (RawModule module = _universe.OpenRawModule(path)) { if (_mscorlibVersion != null) { // to avoid problems (i.e. weird exceptions), we don't allow assemblies to load that reference a newer version of mscorlib foreach (AssemblyName asmref in module.GetReferencedAssemblies()) { if (asmref.Name == "mscorlib" && asmref.Version > _mscorlibVersion) { ConsoleOps.Error(true, "unable to load assembly '{0}' as it depends on a higher version of mscorlib than the one currently loaded", path); } } } Assembly asm = _universe.LoadAssembly(module); if (asm.Location != module.Location && CanonicalizePath(asm.Location) != CanonicalizePath(module.Location)) { ConsoleOps.Warning("assembly '{0}' is ignored as previously loaded assembly '{1}' has the same identity '{2}'", path, asm.Location, asm.FullName); } return(asm); } } catch (IOException x) { ex = x.Message; } catch (UnauthorizedAccessException x) { ex = x.Message; } catch (IKVM.Reflection.BadImageFormatException x) { ex = x.Message; } ConsoleOps.Error(true, "unable to load assembly '{0}'" + Environment.NewLine + " ({1})", path, ex); return(null); }
internal Assembly LoadFile(string path) { string ex = null; try { using (RawModule module = universe.OpenRawModule(path)) { if (mscorlibVersion != null) { // to avoid problems (i.e. weird exceptions), we don't allow assemblies to load that reference a newer version of mscorlib foreach (AssemblyName asmref in module.GetReferencedAssemblies()) { /*if (asmref.Name.IsReferenceCoreLib() && asmref.Version > mscorlibVersion) * { * Console.Error.WriteLine(asmref.FullName + " > " + mscorlibVersion); * Console.Error.WriteLine("Error: unable to load assembly '{0}' as it depends on a higher version of mscorlib than the one currently loaded", path); * Environment.Exit(1); * }*/ } } Assembly asm = universe.LoadAssembly(module); if (asm.Location != module.Location && CanonicalizePath(asm.Location) != CanonicalizePath(module.Location)) { EmitWarning(WarningId.LocationIgnored, "assembly \"{0}\" is ignored as previously loaded assembly \"{1}\" has the same identity \"{2}\"", path, asm.Location, asm.FullName); } return(asm); } } catch (IOException x) { ex = x.Message; } catch (UnauthorizedAccessException x) { ex = x.Message; } catch (IKVM.Reflection.BadImageFormatException x) { ex = x.Message; } Console.Error.WriteLine("Error: unable to load assembly '{0}'" + Environment.NewLine + " ({1})", path, ex); Environment.Exit(1); return(null); }