public virtual AssemblyDefinition Resolve(AssemblyNameReference name, ReaderParameters parameters) { if (name == null) { throw new ArgumentNullException("name"); } if (parameters == null) { parameters = new ReaderParameters(); } AssemblyDefinition corlib = this.SearchDirectory(name, this.directories, parameters); if (corlib != null) { return(corlib); } if (name.IsRetargetable) { name = new AssemblyNameReference(name.Name, new Version(0, 0, 0, 0)) { PublicKeyToken = Empty <byte> .Array }; } string directoryName = Path.GetDirectoryName(typeof(object).Module.FullyQualifiedName); if (BaseAssemblyResolver.IsZero(name.Version)) { corlib = this.SearchDirectory(name, new string[] { directoryName }, parameters); if (corlib != null) { return(corlib); } } if (name.Name == "mscorlib") { corlib = this.GetCorlib(name, parameters); if (corlib != null) { return(corlib); } } corlib = this.GetAssemblyInGac(name, parameters); if (corlib != null) { return(corlib); } corlib = this.SearchDirectory(name, new string[] { directoryName }, parameters); if (corlib != null) { return(corlib); } if (this.ResolveFailure != null) { corlib = this.ResolveFailure(this, name); if (corlib != null) { return(corlib); } } throw new AssemblyResolutionException(name); }
private AssemblyDefinition GetCorlib(AssemblyNameReference reference, ReaderParameters parameters) { Version version = reference.Version; if (typeof(object).Assembly.GetName().Version == version || BaseAssemblyResolver.IsZero(version)) { return(this.GetAssembly(typeof(object).Module.FullyQualifiedName, parameters)); } string fullName = Directory.GetParent(Directory.GetParent(typeof(object).Module.FullyQualifiedName).FullName).FullName; if (!BaseAssemblyResolver.on_mono) { switch (version.Major) { case 1: { if (version.MajorRevision != 3300) { fullName = Path.Combine(fullName, "v1.0.5000.0"); break; } else { fullName = Path.Combine(fullName, "v1.0.3705"); break; } } case 2: { fullName = Path.Combine(fullName, "v2.0.50727"); break; } case 3: { throw new NotSupportedException(string.Concat("Version not supported: ", version)); } case 4: { fullName = Path.Combine(fullName, "v4.0.30319"); break; } default: { throw new NotSupportedException(string.Concat("Version not supported: ", version)); } } } else if (version.Major == 1) { fullName = Path.Combine(fullName, "1.0"); } else if (version.Major != 2) { if (version.Major != 4) { throw new NotSupportedException(string.Concat("Version not supported: ", version)); } fullName = Path.Combine(fullName, "4.0"); } else { fullName = (version.MajorRevision != 5 ? Path.Combine(fullName, "2.0") : Path.Combine(fullName, "2.1")); } string str = Path.Combine(fullName, "mscorlib.dll"); if (!File.Exists(str)) { return(null); } return(this.GetAssembly(str, parameters)); }