public Assembly ResolveAssembly(AssemblyName assemblyName)
 {
     try
     {
         AssemblyName assemblyName1 = ClrAssemblyResolver.Redirect(assemblyName);
         if (assemblyName1 != null)
         {
             string assemblyFullName = ProjectAssemblyHelper.UncachedGetAssemblyFullName(assemblyName1);
             foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
             {
                 if (assembly.FullName == assemblyFullName && assembly.GlobalAssemblyCache)
                 {
                     return(assembly);
                 }
             }
             if (this.resolveAttempts.Add(assemblyFullName))
             {
                 return(ProjectAssemblyHelper.Load(assemblyName1));
             }
         }
     }
     catch (BadImageFormatException ex)
     {
     }
     catch (IOException ex)
     {
     }
     return((Assembly)null);
 }
        private static AssemblyName Redirect(AssemblyName assemblyName)
        {
            string name = assemblyName.Name;

            byte[] publicKeyToken = assemblyName.GetPublicKeyToken();
            if (publicKeyToken != null)
            {
                string strA = ClrAssemblyResolver.ByteArrayToString(publicKeyToken);
                for (int index = 0; index < ClrAssemblyResolver.frameworkMapping.GetLength(0); ++index)
                {
                    string strB1 = ClrAssemblyResolver.frameworkMapping[index][0];
                    string strB2 = ClrAssemblyResolver.frameworkMapping[index][1];
                    if (string.Compare(name, strB1, StringComparison.OrdinalIgnoreCase) == 0 && string.Compare(strA, strB2, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        return new AssemblyName(ProjectAssemblyHelper.CachedGetAssemblyFullName(assemblyName))
                               {
                                   Version = new Version(ClrAssemblyResolver.frameworkMapping[index][2])
                               }
                    }
                    ;
                }
                for (int index = 0; index < ClrAssemblyResolver.retargetMapping.GetLength(0); ++index)
                {
                    string strB1 = ClrAssemblyResolver.retargetMapping[index][0];
                    string strB2 = ClrAssemblyResolver.retargetMapping[index][1];
                    if (string.Compare(name, strB1, StringComparison.OrdinalIgnoreCase) == 0 && string.Compare(strA, strB2, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        Version version1 = assemblyName.Version;

                        string[] strArray = ClrAssemblyResolver.retargetMapping[index][2].Split('-');
                        Version  version2 = new Version(strArray[0]);
                        Version  version3 = new Version(strArray.Length == 1 ? strArray[0] : strArray[1]);
                        if (version1 >= version2 && version1 <= version3)
                        {
                            AssemblyName assemblyName1 = new AssemblyName(ProjectAssemblyHelper.CachedGetAssemblyFullName(assemblyName));
                            assemblyName1.Name = ClrAssemblyResolver.retargetMapping[index][3] == null ? assemblyName1.Name : ClrAssemblyResolver.retargetMapping[index][3];
                            assemblyName1.SetPublicKeyToken(ClrAssemblyResolver.ParseByteArray(ClrAssemblyResolver.retargetMapping[index][4]));
                            assemblyName1.Version = new Version(ClrAssemblyResolver.retargetMapping[index][5]);
                            assemblyName1.Flags  &= ~AssemblyNameFlags.Retargetable;
                            return(assemblyName1);
                        }
                    }
                }
            }
            return((AssemblyName)null);
        }