LoadedAssembly LookupReferencedAssemblyInternal(string fullName, ModuleDef sourceModule, bool delay) { var asm = assemblyList.FindAssemblyByAssemblyName(fullName); if (asm != null) { return(asm); } var name = new AssemblyNameInfo(fullName); var loadedAsm = LookupFromSearchPaths(name, sourceModule, true); if (loadedAsm != null) { return(assemblyList.AddAssembly(loadedAsm, assemblyLoadDisableCount == 0, delay)); } if (assemblyList.UseGAC) { var file = GacInterop.FindAssemblyInNetGac(name); if (file != null) { return(assemblyList.OpenAssemblyInternal(file, assemblyLoadDisableCount == 0, true, delay)); } foreach (var path in otherGacPaths) { loadedAsm = TryLoadFromDir(name, true, path); if (loadedAsm != null) { return(assemblyList.AddAssembly(loadedAsm, assemblyLoadDisableCount == 0, delay)); } } } loadedAsm = LookupFromSearchPaths(name, sourceModule, false); if (loadedAsm != null) { return(assemblyList.AddAssembly(loadedAsm, assemblyLoadDisableCount == 0, delay)); } return(null); }
void FetchGacContents() { HashSet <string> fullNames = new HashSet <string>(); foreach (var r in GacInterop.GetGacAssemblyFullNames()) { if (cancelFetchThread) { return; } if (fullNames.Add(r.FullName)) // filter duplicates { var file = GacInterop.FindAssemblyInNetGac(r); if (file != null) { var entry = new GacEntry(r, file); Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action <GacEntry>(AddNewEntry), entry); } } } }
public LoadedAssembly LookupReferencedAssembly(string fullName) { foreach (LoadedAssembly asm in assemblyList.GetAssemblies()) { if (asm.AssemblyDefinition != null && fullName.Equals(asm.AssemblyDefinition.FullName, StringComparison.OrdinalIgnoreCase)) { return(asm); } } if (!App.Current.Dispatcher.CheckAccess()) { // Call this method on the GUI thread. return((LoadedAssembly)App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Func <string, LoadedAssembly>(LookupReferencedAssembly), fullName)); } var name = AssemblyNameReference.Parse(fullName); string file = GacInterop.FindAssemblyInNetGac(name); if (file == null) { string dir = Path.GetDirectoryName(this.fileName); if (File.Exists(Path.Combine(dir, name.Name + ".dll"))) { file = Path.Combine(dir, name.Name + ".dll"); } else if (File.Exists(Path.Combine(dir, name.Name + ".exe"))) { file = Path.Combine(dir, name.Name + ".exe"); } } if (file != null) { return(assemblyList.OpenAssembly(file)); } else { return(null); } }
LoadedAssembly LookupReferencedAssemblyInternal(string fullName) { foreach (LoadedAssembly asm in assemblyList.GetAssemblies()) { if (asm.AssemblyDefinition != null && fullName.Equals(asm.AssemblyDefinition.FullName, StringComparison.OrdinalIgnoreCase)) { return(asm); } } if (assemblyLoadDisableCount > 0) { return(null); } if (!App.Current.Dispatcher.CheckAccess()) { // Call this method on the GUI thread. return((LoadedAssembly)App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Func <string, LoadedAssembly>(LookupReferencedAssembly), fullName)); } var targetFramework = TargetFrameworkId.Split(new[] { ",Version=v" }, StringSplitOptions.None); var name = AssemblyNameReference.Parse(fullName); string file = null; switch (targetFramework[0]) { case ".NETCoreApp": case ".NETStandard": if (targetFramework.Length != 2) { break; } if (dotNetCorePathFinder == null) { var version = targetFramework[1].Length == 3 ? targetFramework[1] + ".0" : targetFramework[1]; dotNetCorePathFinder = new DotNetCorePathFinder(fileName, TargetFrameworkId, version, this.loadedAssemblyReferences); } file = dotNetCorePathFinder.TryResolveDotNetCore(name); break; default: file = GacInterop.FindAssemblyInNetGac(name); break; } if (file == null) { string dir = Path.GetDirectoryName(this.fileName); if (File.Exists(Path.Combine(dir, name.Name + ".dll"))) { file = Path.Combine(dir, name.Name + ".dll"); } else if (File.Exists(Path.Combine(dir, name.Name + ".exe"))) { file = Path.Combine(dir, name.Name + ".exe"); } } if (file != null) { loadedAssemblyReferences.AddMessage(fullName, MessageKind.Info, "Success - Loading from: " + file); return(assemblyList.OpenAssembly(file, true)); } else { loadedAssemblyReferences.AddMessage(fullName, MessageKind.Error, "Could not find reference: " + fullName); return(null); } }