// Token: 0x0600003B RID: 59 RVA: 0x00003A2C File Offset: 0x00001C2C private static bool LoadSatelliteByPath(AssemblyName resolve, string fullPath, bool isLog, bool first, out Assembly resolvedAssembly) { AssemblyName assemblyName = AssemblyName.GetAssemblyName(fullPath); if (!AssemblySatelliteResolver.SatelliteMatchesDefinition(resolve, assemblyName)) { if (isLog) { AssemblySatelliteResolver.log.DebugFormat("Resolving \"{0}\" does not match \"{1}\"", resolve, assemblyName); } resolvedAssembly = null; return(false); } Exception ex = null; Assembly assembly = null; if (first) { try { assembly = Assembly.Load(assemblyName); } catch (FileNotFoundException) { } catch (FileLoadException) { } catch (Exception ex) { } } if (assembly == null) { if (ex != null) { AssemblySatelliteResolver.log.DebugFormat("Cannot load \"{0}\", falling back to load-from. {1}", assemblyName, ex); } assembly = Assembly.LoadFrom(fullPath); } try { if (AssemblySatelliteResolver.ResolveCnt.GetOrAdd(assembly.FullName, (string _) => new AssemblySatelliteResolver.IntRef(0)).Increment() == 1 || isLog) { Uri assemblyLocation = AssemblySatelliteResolver.GetAssemblyLocation(assembly); string text = (assemblyLocation != null && assemblyLocation.IsAbsoluteUri) ? AssemblySatelliteResolver.NormalizePath(assemblyLocation.LocalPath) : string.Empty; if (!AssemblyName.ReferenceMatchesDefinition(resolve, assembly.GetName()) || !fullPath.Equals(text, StringComparison.Ordinal)) { AssemblySatelliteResolver.log.ErrorFormat("Resolved \"{0}\" as \"{1}\" at \"{2}\"", resolve, assembly, text); } } } catch (Exception ex2) { AssemblySatelliteResolver.log.ErrorFormat("Error reporting assembly-resolved. {0}", ex2); } resolvedAssembly = assembly; return(true); }
// Token: 0x06000030 RID: 48 RVA: 0x00002FD4 File Offset: 0x000011D4 internal static Assembly AssemblyResolve(object sender, ResolveEventArgs args) { try { AssemblyName assemblyName = new AssemblyName(args.Name); if (!assemblyName.Name.EndsWith(".resources", StringComparison.OrdinalIgnoreCase)) { return(null); } AssemblySatelliteResolver.IntRef intRef; bool flag = AssemblySatelliteResolver.EntryCount.GetOrAdd(assemblyName.FullName, (string _) => new AssemblySatelliteResolver.IntRef(0)).Increment() > 2 && !AssemblySatelliteResolver.ResolveCnt.TryGetValue(assemblyName.FullName, out intRef); if (flag) { AssemblySatelliteResolver.log.DebugFormat("Resolving satellite assembly \"{0}\"", assemblyName); } string[] array = assemblyName.Name.Split(new char[] { '.' }); string sourceName = string.Join(".", array.Take(array.Length - 1)); string resolveFileName = assemblyName.Name + ".dll"; List <Assembly> list = new List <Assembly>(AppDomain.CurrentDomain.GetAssemblies()); Assembly requestingAssembly = args.RequestingAssembly; if (requestingAssembly != null) { list.Remove(requestingAssembly); list.Insert(0, requestingAssembly); } foreach (Assembly assembly in list) { AssemblyName name = assembly.GetName(); if (AssemblySatelliteResolver.SatelliteMatchesDefinition(assemblyName, name)) { bool flag2 = AssemblySatelliteResolver.ResolveCnt.GetOrAdd(assembly.FullName, (string _) => new AssemblySatelliteResolver.IntRef(0)).Increment() == 1; if (flag || flag2) { AssemblySatelliteResolver.log.InfoFormat("Resolved \"{0}\" as \"{1}\" at \"{2}\"", assemblyName, name, AssemblySatelliteResolver.GetSymbolicLocation(assembly)); } return(assembly); } } Assembly result; if (AssemblySatelliteResolver.ProbeViaLoadedAssemblies(list, assemblyName, resolveFileName, requestingAssembly, sourceName, flag, out result)) { return(result); } } catch (Exception ex) { Trace.TraceError("AssemblyResove failed. {0}", new object[] { ex }); AssemblySatelliteResolver.log.FatalFormat("AssemblyResove failed. {0}", ex); GC.KeepAlive(ex); } return(null); }
private static bool ProbeForAssemblySatellite( IEnumerable <Uri> loadedUris, List <string> cultures, AssemblyName resolve, string resolveFileName, bool isLog, bool first, out Assembly resolvedAssembly) { HashSet <string> stringSet = new HashSet <string>((IEqualityComparer <string>)StringComparer.Ordinal); foreach (Uri loadedUri in loadedUris) { string localPath; if (loadedUri.IsAbsoluteUri && !string.IsNullOrEmpty(localPath = loadedUri.LocalPath)) { string loadedPath = (string)null; try { loadedPath = AssemblySatelliteResolver.NormalizePath(Path.GetDirectoryName(localPath)); } catch (Exception ex) { AssemblySatelliteResolver.log.DebugFormat("Cannot get directory path of \"{0}\". {1}", (object)localPath, (object)ex); } if (!string.IsNullOrEmpty(loadedPath) && stringSet.Add(loadedPath)) { List <string> list = cultures.Select <string, string>((Func <string, string>)(culture => Path.Combine(loadedPath, culture, resolveFileName))).Select <string, string>(new Func <string, string>(AssemblySatelliteResolver.NormalizePath)).Where <string>(new Func <string, bool>(File.Exists)).ToList <string>(); if (isLog && AssemblySatelliteResolver.log.get_IsDebugEnabled() && list.Count < 1) { AssemblySatelliteResolver.log.DebugFormat("Resolving \"{0}\" cannot find ({2}) satellite for \"{1}\"", (object)resolve, (object)loadedPath, (object)string.Join(", ", (IEnumerable <string>)cultures)); } foreach (string fullPath in list) { try { if (AssemblySatelliteResolver.LoadSatelliteByPath(resolve, fullPath, isLog, first, out resolvedAssembly)) { return(true); } } catch (Exception ex) { AssemblySatelliteResolver.log.ErrorFormat("Error resolving \"{0}\" as \"{1}\". {2}", (object)resolve, (object)fullPath, (object)ex); } } } } } resolvedAssembly = (Assembly)null; return(false); }
internal static Assembly AssemblyResolve(object sender, ResolveEventArgs args) { try { AssemblyName assemblyName = new AssemblyName(args.Name); if (!assemblyName.Name.EndsWith(".resources", StringComparison.OrdinalIgnoreCase)) { return((Assembly)null); } bool isLog = AssemblySatelliteResolver.EntryCount.GetOrAdd(assemblyName.FullName, (Func <string, AssemblySatelliteResolver.IntRef>)(_ => new AssemblySatelliteResolver.IntRef(0))).Increment() > 2 && !AssemblySatelliteResolver.ResolveCnt.TryGetValue(assemblyName.FullName, out AssemblySatelliteResolver.IntRef _); if (isLog) { AssemblySatelliteResolver.log.DebugFormat("Resolving satellite assembly \"{0}\"", (object)assemblyName); } string[] strArray = assemblyName.Name.Split('.'); string sourceName = string.Join(".", ((IEnumerable <string>)strArray).Take <string>(strArray.Length - 1)); string resolveFileName = assemblyName.Name + ".dll"; List <Assembly> assemblyList = new List <Assembly>((IEnumerable <Assembly>)AppDomain.CurrentDomain.GetAssemblies()); Assembly requestingAssembly = args.RequestingAssembly; if (requestingAssembly != (Assembly)null) { assemblyList.Remove(requestingAssembly); assemblyList.Insert(0, requestingAssembly); } foreach (Assembly assembly in assemblyList) { AssemblyName name = assembly.GetName(); if (AssemblySatelliteResolver.SatelliteMatchesDefinition(assemblyName, name)) { bool flag = AssemblySatelliteResolver.ResolveCnt.GetOrAdd(assembly.FullName, (Func <string, AssemblySatelliteResolver.IntRef>)(_ => new AssemblySatelliteResolver.IntRef(0))).Increment() == 1; if (isLog | flag) { AssemblySatelliteResolver.log.InfoFormat("Resolved \"{0}\" as \"{1}\" at \"{2}\"", (object)assemblyName, (object)name, (object)AssemblySatelliteResolver.GetSymbolicLocation(assembly)); } return(assembly); } } Assembly resolvedAssembly; if (AssemblySatelliteResolver.ProbeViaLoadedAssemblies((ICollection <Assembly>)assemblyList, assemblyName, resolveFileName, requestingAssembly, sourceName, isLog, out resolvedAssembly)) { return(resolvedAssembly); } } catch (Exception ex) { Trace.TraceError("AssemblyResove failed. {0}", (object)ex); AssemblySatelliteResolver.log.FatalFormat("AssemblyResove failed. {0}", (object)ex); GC.KeepAlive((object)ex); } return((Assembly)null); }
private static string GetSymbolicLocation(Assembly assembly) { Uri assemblyLocation = AssemblySatelliteResolver.GetAssemblyLocation(assembly); if (assemblyLocation != (Uri)null) { return(assemblyLocation.ToString()); } if (assembly.IsDynamic) { return("«dynamic»"); } return(assembly.GlobalAssemblyCache ? "«GAC»" : "«unknown»"); }
// Token: 0x0600003A RID: 58 RVA: 0x00003818 File Offset: 0x00001A18 private static bool ProbeForAssemblySatellite(IEnumerable <Uri> loadedUris, List <string> cultures, AssemblyName resolve, string resolveFileName, bool isLog, bool first, out Assembly resolvedAssembly) { HashSet <string> hashSet = new HashSet <string>(StringComparer.Ordinal); foreach (Uri uri in loadedUris) { string localPath; if (uri.IsAbsoluteUri && !string.IsNullOrEmpty(localPath = uri.LocalPath)) { string loadedPath = null; try { loadedPath = AssemblySatelliteResolver.NormalizePath(Path.GetDirectoryName(localPath)); } catch (Exception ex) { AssemblySatelliteResolver.log.DebugFormat("Cannot get directory path of \"{0}\". {1}", localPath, ex); } if (!string.IsNullOrEmpty(loadedPath) && hashSet.Add(loadedPath)) { List <string> list = (from culture in cultures select Path.Combine(loadedPath, culture, resolveFileName)).Select(new Func <string, string>(AssemblySatelliteResolver.NormalizePath)).Where(new Func <string, bool>(File.Exists)).ToList <string>(); if (isLog && AssemblySatelliteResolver.log.IsDebugEnabled && list.Count < 1) { AssemblySatelliteResolver.log.DebugFormat("Resolving \"{0}\" cannot find ({2}) satellite for \"{1}\"", resolve, loadedPath, string.Join(", ", cultures)); } foreach (string text in list) { try { if (AssemblySatelliteResolver.LoadSatelliteByPath(resolve, text, isLog, first, out resolvedAssembly)) { return(true); } } catch (Exception ex2) { AssemblySatelliteResolver.log.ErrorFormat("Error resolving \"{0}\" as \"{1}\". {2}", resolve, text, ex2); } } } } } resolvedAssembly = null; return(false); }
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: 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); }
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); } }
private static bool LoadSatelliteByPath( AssemblyName resolve, string fullPath, bool isLog, bool first, out Assembly resolvedAssembly) { AssemblyName assemblyName = AssemblyName.GetAssemblyName(fullPath); if (!AssemblySatelliteResolver.SatelliteMatchesDefinition(resolve, assemblyName)) { if (isLog) { AssemblySatelliteResolver.log.DebugFormat("Resolving \"{0}\" does not match \"{1}\"", (object)resolve, (object)assemblyName); } resolvedAssembly = (Assembly)null; return(false); } Exception exception = (Exception)null; Assembly assembly = (Assembly)null; if (first) { try { assembly = Assembly.Load(assemblyName); } catch (FileNotFoundException ex) { } catch (FileLoadException ex) { } catch (Exception ex) { exception = ex; } } if (assembly == (Assembly)null) { if (exception != null) { AssemblySatelliteResolver.log.DebugFormat("Cannot load \"{0}\", falling back to load-from. {1}", (object)assemblyName, (object)exception); } assembly = Assembly.LoadFrom(fullPath); } try { if (AssemblySatelliteResolver.ResolveCnt.GetOrAdd(assembly.FullName, (Func <string, AssemblySatelliteResolver.IntRef>)(_ => new AssemblySatelliteResolver.IntRef(0))).Increment() == 1 | isLog) { Uri assemblyLocation = AssemblySatelliteResolver.GetAssemblyLocation(assembly); string str = !(assemblyLocation != (Uri)null) || !assemblyLocation.IsAbsoluteUri ? string.Empty : AssemblySatelliteResolver.NormalizePath(assemblyLocation.LocalPath); if (AssemblyName.ReferenceMatchesDefinition(resolve, assembly.GetName())) { if (fullPath.Equals(str, StringComparison.Ordinal)) { goto label_19; } } AssemblySatelliteResolver.log.ErrorFormat("Resolved \"{0}\" as \"{1}\" at \"{2}\"", (object)resolve, (object)assembly, (object)str); } } catch (Exception ex) { AssemblySatelliteResolver.log.ErrorFormat("Error reporting assembly-resolved. {0}", (object)ex); } label_19: resolvedAssembly = assembly; return(true); }
private static Uri GetAssemblyLocation(Assembly assembly) { return(AssemblySatelliteResolver.GetAssemblyBaseUris(assembly).LastOrDefault <Uri>()); }
// 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); } }