private static Assembly GetAssembly(AssemblyName assemblyName) { if (assemblyCache == null) { lock (assemblyCacheLock) { if (assemblyCache == null) { assemblyCache = new Hashtable(100, new AssemblyNameEqualityComparer()); } } } Assembly assembly = assemblyCache[assemblyName] as Assembly; if (assembly == null) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = assemblies.Length - 1; i >= 0; i--) { Assembly assembly2 = assemblies[i]; if (!assembly2.IsDynamic) { AssemblyName fastAssemblyName = GetFastAssemblyName(assembly2); Version version = fastAssemblyName.Version; CultureInfo cultureInfo = fastAssemblyName.CultureInfo; byte[] publicKeyToken = fastAssemblyName.GetPublicKeyToken(); Version version2 = assemblyName.Version; CultureInfo info2 = assemblyName.CultureInfo; byte[] reqKeyToken = assemblyName.GetPublicKeyToken(); if ((((string.Compare(fastAssemblyName.Name, assemblyName.Name, StringComparison.OrdinalIgnoreCase) == 0) && ((version2 == null) || version2.Equals(version))) && ((info2 == null) || info2.Equals(cultureInfo))) && ((reqKeyToken == null) || AssemblyNameEqualityComparer.IsSameKeyToken(reqKeyToken, publicKeyToken))) { lock (assemblyCacheLock) { assemblyCache[assemblyName] = assembly2; return(assembly2); } } } } assembly = LoadAssembly(assemblyName); if (assembly == null) { return(assembly); } lock (assemblyCacheLock) { assemblyCache[assemblyName] = assembly; } } return(assembly); }