Ejemplo n.º 1
0
        void FetchGacContents()
        {
            HashSet <string> fullNames = new HashSet <string>();

            UpdateProgressBar(pg => { pg.Visibility = System.Windows.Visibility.Visible; pg.IsIndeterminate = true; });
            var list = GacInterop.GetGacAssemblyFullNames().TakeWhile(_ => !cancelFetchThread).ToList();

            UpdateProgressBar(pg => { pg.IsIndeterminate = false; pg.Maximum = list.Count; });
            foreach (var r in list)
            {
                if (cancelFetchThread)
                {
                    break;
                }
                if (fullNames.Add(r.FullName))                   // filter duplicates
                {
                    var file = GacInterop.FindAssemblyInNetGac(r);
                    if (file != null)
                    {
                        var entry = new GacEntry(r, file);
                        UpdateProgressBar(pg => { pg.Value = pg.Value + 1; AddNewEntry(entry); });
                    }
                }
            }
            UpdateProgressBar(pg => { pg.Visibility = System.Windows.Visibility.Hidden; });
        }
Ejemplo n.º 2
0
        private void AddToList(AssemblyList list, string FullName)
        {
            AssemblyNameInfo reference = new AssemblyNameInfo(FullName);
            string           file      = GacInterop.FindAssemblyInNetGac(reference);

            if (file != null)
            {
                list.OpenAssembly(file);
            }
        }
Ejemplo n.º 3
0
        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 !CORE
            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));
            }
#endif

            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);
            }
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        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);
            }
        }