// Token: 0x06000039 RID: 57 RVA: 0x000036CC File Offset: 0x000018CC
        private static bool ProbeViaLoadedAssemblies(ICollection <Assembly> loadedAssemblies, AssemblyName resolve, string resolveFileName, Assembly requesting, string sourceName, bool isLog, out Assembly resolvedAssembly)
        {
            bool       first = AssemblySatelliteResolver.EntryCount.GetOrAdd(resolve.Name, (string _) => new AssemblySatelliteResolver.IntRef(0)).Increment() == 1;
            List <Uri> list  = new List <Uri>(loadedAssemblies.Count);

            foreach (Assembly assembly in loadedAssemblies)
            {
                AssemblyName name = assembly.GetName();
                if (!(requesting != null) || requesting.Equals(assembly) || name.Name.Equals(sourceName, StringComparison.OrdinalIgnoreCase))
                {
                    list.AddRange(AssemblySatelliteResolver.GetAssemblyBaseUris(assembly));
                }
            }
            List <string> list2 = AssemblySatelliteResolver.ExpandCulture(resolve.CultureInfo).ToList <string>();
            Assembly      assembly2;

            if (AssemblySatelliteResolver.ProbeForAssemblySatellite(list, list2, resolve, resolveFileName, isLog, first, out assembly2))
            {
                resolvedAssembly = assembly2;
                return(true);
            }
            if (isLog)
            {
                string text = string.Format("Cannot resolve \"{0}\".{1}", resolve, AssemblySatelliteResolver.GetDebugStackTrace());
                if (resolve.Name.StartsWith("SolarWinds", StringComparison.OrdinalIgnoreCase) && LocaleConfiguration.InstalledLocales.Intersect(list2, StringComparer.OrdinalIgnoreCase).Any <string>())
                {
                    AssemblySatelliteResolver.log.Warn(text);
                }
                else
                {
                    AssemblySatelliteResolver.log.Debug(text);
                }
            }
            resolvedAssembly = null;
            return(false);
        }
コード例 #2
0
        internal static void AssemblyLoad(object sender, AssemblyLoadEventArgs args)
        {
            if (!AssemblySatelliteResolver.log.get_IsErrorEnabled())
            {
                return;
            }
            try
            {
                Assembly      loadedAssembly = args.LoadedAssembly;
                AssemblyName  name           = loadedAssembly.GetName();
                StringBuilder stringBuilder1 = new StringBuilder();
                int           num            = 1;
                bool          flag1          = name.Name.EndsWith(".resources", StringComparison.OrdinalIgnoreCase);
                bool          flag2          = name.Name.IndexOf("Auditing", StringComparison.OrdinalIgnoreCase) > -1;
                bool          flag3          = name.Name.IndexOf(".Strings", StringComparison.OrdinalIgnoreCase) > -1;
                if (flag1)
                {
                    AssemblySatelliteResolver.IntRef intRef;
                    if (!AssemblySatelliteResolver.EntryCount.TryGetValue(name.FullName, out intRef) && !AssemblySatelliteResolver.ResolveCnt.TryGetValue(name.FullName, out intRef))
                    {
                        num = 2;
                    }
                    string[] strArray   = name.Name.Split('.');
                    string   sourceName = string.Join(".", ((IEnumerable <string>)strArray).Take <string>(strArray.Length - 1));
                    Assembly assembly1  = ((IEnumerable <Assembly>)AppDomain.CurrentDomain.GetAssemblies()).FirstOrDefault <Assembly>((Func <Assembly, bool>)(a => a.GetName().Name.Equals(sourceName, StringComparison.OrdinalIgnoreCase)));
                    if (assembly1 != (Assembly)null)
                    {
                        Assembly assembly2 = (Assembly)null;
                        try
                        {
                            assembly2 = assembly1.GetSatelliteAssembly(name.CultureInfo);
                        }
                        catch (FileNotFoundException ex)
                        {
                        }
                        catch (FileLoadException ex)
                        {
                        }
                        if (assembly2 == (Assembly)null || assembly2 != loadedAssembly)
                        {
                            stringBuilder1.AppendLine().AppendFormat("Unexpected satellite for \"{0}\" : \"{1}\"", (object)loadedAssembly, (object)name.CultureInfo.Name);
                            num = 3;
                        }
                    }
                }
                if (!(flag1 | flag2 | flag3))
                {
                    return;
                }
                StringBuilder stringBuilder2 = new StringBuilder().AppendFormat("Loaded \"{0}\" at \"{1}\".{2}", (object)name, (object)AssemblySatelliteResolver.GetSymbolicLocation(loadedAssembly), AssemblySatelliteResolver.GetDebugStackTrace()).Append((object)stringBuilder1);
                switch (num)
                {
                case 1:
                    AssemblySatelliteResolver.log.Info((object)stringBuilder2);
                    break;

                case 2:
                    AssemblySatelliteResolver.log.Warn((object)stringBuilder2);
                    break;

                case 3:
                    AssemblySatelliteResolver.log.Error((object)stringBuilder2);
                    break;
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("AssemblyLoad failed. {0}", (object)ex);
                AssemblySatelliteResolver.log.FatalFormat("AssemblyLoad failed. {0}", (object)ex);
                GC.KeepAlive((object)ex);
            }
        }
コード例 #3
0
        private static bool ProbeViaLoadedAssemblies(
            ICollection <Assembly> loadedAssemblies,
            AssemblyName resolve,
            string resolveFileName,
            Assembly requesting,
            string sourceName,
            bool isLog,
            out Assembly resolvedAssembly)
        {
            bool       first   = AssemblySatelliteResolver.EntryCount.GetOrAdd(resolve.Name, (Func <string, AssemblySatelliteResolver.IntRef>)(_ => new AssemblySatelliteResolver.IntRef(0))).Increment() == 1;
            List <Uri> uriList = new List <Uri>(loadedAssemblies.Count);

            foreach (Assembly loadedAssembly in (IEnumerable <Assembly>)loadedAssemblies)
            {
                AssemblyName name = loadedAssembly.GetName();
                if (!(requesting != (Assembly)null) || requesting.Equals((object)loadedAssembly) || name.Name.Equals(sourceName, StringComparison.OrdinalIgnoreCase))
                {
                    uriList.AddRange(AssemblySatelliteResolver.GetAssemblyBaseUris(loadedAssembly));
                }
            }
            List <string> list = AssemblySatelliteResolver.ExpandCulture(resolve.CultureInfo).ToList <string>();
            Assembly      resolvedAssembly1;

            if (AssemblySatelliteResolver.ProbeForAssemblySatellite((IEnumerable <Uri>)uriList, list, resolve, resolveFileName, isLog, first, out resolvedAssembly1))
            {
                resolvedAssembly = resolvedAssembly1;
                return(true);
            }
            if (isLog)
            {
                string str = string.Format("Cannot resolve \"{0}\".{1}", (object)resolve, AssemblySatelliteResolver.GetDebugStackTrace());
                if (resolve.Name.StartsWith("SolarWinds", StringComparison.OrdinalIgnoreCase) && ((IEnumerable <string>)LocaleConfiguration.get_InstalledLocales()).Intersect <string>((IEnumerable <string>)list, (IEqualityComparer <string>)StringComparer.OrdinalIgnoreCase).Any <string>())
                {
                    AssemblySatelliteResolver.log.Warn((object)str);
                }
                else
                {
                    AssemblySatelliteResolver.log.Debug((object)str);
                }
            }
            resolvedAssembly = (Assembly)null;
            return(false);
        }
        // Token: 0x06000031 RID: 49 RVA: 0x00003208 File Offset: 0x00001408
        internal static void AssemblyLoad(object sender, AssemblyLoadEventArgs args)
        {
            if (!AssemblySatelliteResolver.log.IsErrorEnabled)
            {
                return;
            }
            try
            {
                Assembly      loadedAssembly = args.LoadedAssembly;
                AssemblyName  name           = loadedAssembly.GetName();
                StringBuilder stringBuilder  = new StringBuilder();
                int           num            = 1;
                bool          flag           = name.Name.EndsWith(".resources", StringComparison.OrdinalIgnoreCase);
                bool          flag2          = name.Name.IndexOf("Auditing", StringComparison.OrdinalIgnoreCase) > -1;
                bool          flag3          = name.Name.IndexOf(".Strings", StringComparison.OrdinalIgnoreCase) > -1;
                if (flag)
                {
                    AssemblySatelliteResolver.IntRef intRef;
                    if (!AssemblySatelliteResolver.EntryCount.TryGetValue(name.FullName, out intRef) && !AssemblySatelliteResolver.ResolveCnt.TryGetValue(name.FullName, out intRef))
                    {
                        num = 2;
                    }
                    string[] array = name.Name.Split(new char[]
                    {
                        '.'
                    });
                    string   sourceName = string.Join(".", array.Take(array.Length - 1));
                    Assembly assembly   = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name.Equals(sourceName, StringComparison.OrdinalIgnoreCase));
                    if (assembly != null)
                    {
                        Assembly left = null;
                        try
                        {
                            left = assembly.GetSatelliteAssembly(name.CultureInfo);
                        }
                        catch (FileNotFoundException)
                        {
                        }
                        catch (FileLoadException)
                        {
                        }
                        if (left == null || left != loadedAssembly)
                        {
                            stringBuilder.AppendLine().AppendFormat("Unexpected satellite for \"{0}\" : \"{1}\"", loadedAssembly, name.CultureInfo.Name);
                            num = 3;
                        }
                    }
                }
                if (flag || flag2 || flag3)
                {
                    StringBuilder stringBuilder2 = new StringBuilder().AppendFormat("Loaded \"{0}\" at \"{1}\".{2}", name, AssemblySatelliteResolver.GetSymbolicLocation(loadedAssembly), AssemblySatelliteResolver.GetDebugStackTrace()).Append(stringBuilder);
                    switch (num)
                    {
                    case 1:
                        AssemblySatelliteResolver.log.Info(stringBuilder2);
                        break;

                    case 2:
                        AssemblySatelliteResolver.log.Warn(stringBuilder2);
                        break;

                    case 3:
                        AssemblySatelliteResolver.log.Error(stringBuilder2);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("AssemblyLoad failed. {0}", new object[]
                {
                    ex
                });
                AssemblySatelliteResolver.log.FatalFormat("AssemblyLoad failed. {0}", ex);
                GC.KeepAlive(ex);
            }
        }