コード例 #1
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);
        }