Пример #1
0
        private static NetFX35SP1SKU GetPlatformNetFx35SKU(System.Deployment.Application.NativeMethods.IAssemblyCache AssemblyCache, bool targetOtherCLR, System.Deployment.Application.NativeMethods.CCorRuntimeHost RuntimeHost, string tempDir)
        {
            ReferenceIdentity refId     = new ReferenceIdentity("Sentinel.v3.5Client, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,processorArchitecture=msil");
            ReferenceIdentity identity2 = new ReferenceIdentity("System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089,processorArchitecture=msil");
            bool flag  = false;
            bool flag2 = false;

            if (VerifyGACDependency(AssemblyCache, targetOtherCLR, RuntimeHost, refId, tempDir))
            {
                flag = true;
            }
            if (VerifyGACDependency(AssemblyCache, targetOtherCLR, RuntimeHost, identity2, tempDir))
            {
                flag2 = true;
            }
            if (flag && !flag2)
            {
                return(NetFX35SP1SKU.Client35SP1);
            }
            if (flag && flag2)
            {
                return(NetFX35SP1SKU.Full35SP1);
            }
            return(NetFX35SP1SKU.No35SP1);
        }
Пример #2
0
 public bool Matches(ReferenceIdentity refId, bool exact)
 {
     if (IsolationInterop.IdentityAuthority.DoesDefinitionMatchReference(exact ? 1U : 0U, this._idComPtr, refId.ComPointer))
     {
         return(this.Version == refId.Version);
     }
     return(false);
 }
Пример #3
0
 public DefinitionIdentity(ReferenceIdentity refId)
 {
     this._idComPtr = IsolationInterop.IdentityAuthority.CreateDefinition();
     foreach (IDENTITY_ATTRIBUTE attribute in refId.Attributes)
     {
         this[attribute.Namespace, attribute.Name] = attribute.Value;
     }
 }
Пример #4
0
        public static bool VerifyGACDependencyWhidbey(System.Deployment.Application.NativeMethods.IAssemblyCache AssemblyCache, bool targetOtherClr, System.Deployment.Application.NativeMethods.CCorRuntimeHost RuntimeHost, ReferenceIdentity refId)
        {
            ReferenceIdentity identity;

            System.Deployment.Application.NativeMethods.IAssemblyName name;
            System.Deployment.Application.NativeMethods.IAssemblyEnum enum2;
            string str  = refId.ToString();
            string text = null;

            if (targetOtherClr)
            {
                try
                {
                    text = RuntimeHost.ApplyPolicyInOtherRuntime(str);
                    goto Label_0048;
                }
                catch (ArgumentException)
                {
                    return(false);
                }
                catch (COMException)
                {
                    return(false);
                }
            }
            try
            {
                text = AppDomain.CurrentDomain.ApplyPolicy(str);
            }
            catch (ArgumentException)
            {
                return(false);
            }
            catch (COMException)
            {
                return(false);
            }
Label_0048:
            identity = new ReferenceIdentity(text);
            identity.ProcessorArchitecture = refId.ProcessorArchitecture;
            string assemblyName = identity.ToString();

            Logger.AddPhaseInformation(Resources.GetString("DetectingDependentAssembly"), new object[] { str, assemblyName });
            SystemUtils.AssemblyInfo info = null;
            info = SystemUtils.QueryAssemblyInfo(AssemblyCache, SystemUtils.QueryAssemblyInfoFlags.All, assemblyName);
            if ((info != null) || (identity.ProcessorArchitecture != null))
            {
                return(info != null);
            }
            System.Deployment.Application.NativeMethods.CreateAssemblyNameObject(out name, identity.ToString(), 1, IntPtr.Zero);
            System.Deployment.Application.NativeMethods.CreateAssemblyEnum(out enum2, null, name, 2, IntPtr.Zero);
            return(enum2.GetNextAssembly(null, out name, 0) == 0);
        }
Пример #5
0
        public static bool VerifyGACDependencyWhidbey(NativeMethods.IAssemblyCache AssemblyCache, bool targetOtherClr, NativeMethods.CCorRuntimeHost RuntimeHost, ReferenceIdentity refId)
        {
            string str = refId.ToString();
            string text;

            if (targetOtherClr)
            {
                try
                {
                    text = RuntimeHost.ApplyPolicyInOtherRuntime(str);
                }
                catch (ArgumentException ex)
                {
                    return(false);
                }
                catch (COMException ex)
                {
                    return(false);
                }
            }
            else
            {
                try
                {
                    text = AppDomain.CurrentDomain.ApplyPolicy(str);
                }
                catch (ArgumentException ex)
                {
                    return(false);
                }
                catch (COMException ex)
                {
                    return(false);
                }
            }
            ReferenceIdentity referenceIdentity = new ReferenceIdentity(text);

            referenceIdentity.ProcessorArchitecture = refId.ProcessorArchitecture;
            string assemblyName = referenceIdentity.ToString();

            Logger.AddPhaseInformation(Resources.GetString("DetectingDependentAssembly"), (object)str, (object)assemblyName);
            SystemUtils.AssemblyInfo assemblyInfo = SystemUtils.QueryAssemblyInfo(AssemblyCache, SystemUtils.QueryAssemblyInfoFlags.All, assemblyName);
            if (assemblyInfo != null || referenceIdentity.ProcessorArchitecture != null)
            {
                return(assemblyInfo != null);
            }
            NativeMethods.IAssemblyName pName;
            NativeMethods.CreateAssemblyNameObject(out pName, referenceIdentity.ToString(), 1U, IntPtr.Zero);
            NativeMethods.IAssemblyEnum ppEnum;
            NativeMethods.CreateAssemblyEnum(out ppEnum, (NativeMethods.IApplicationContext)null, pName, 2U, IntPtr.Zero);
            return(ppEnum.GetNextAssembly((NativeMethods.IApplicationContext)null, out pName, 0U) == 0);
        }
Пример #6
0
        public DependentAssembly(System.Deployment.Internal.Isolation.Manifest.AssemblyReferenceEntry assemblyReferenceEntry)
        {
            this._hashCollection = new System.Deployment.Application.HashCollection();
            System.Deployment.Internal.Isolation.Manifest.AssemblyReferenceDependentAssemblyEntry dependentAssembly = assemblyReferenceEntry.DependentAssembly;
            this._size     = dependentAssembly.Size;
            this._codebase = dependentAssembly.Codebase;
            this._group    = dependentAssembly.Group;
            bool flag = false;

            System.Deployment.Internal.Isolation.ISection hashElements = dependentAssembly.HashElements;
            uint celt = (hashElements != null) ? hashElements.Count : 0;

            if (celt > 0)
            {
                uint celtFetched = 0;
                System.Deployment.Internal.Isolation.Manifest.IHashElementEntry[] rgelt = new System.Deployment.Internal.Isolation.Manifest.IHashElementEntry[celt];
                System.Deployment.Internal.Isolation.IEnumUnknown unknown = (System.Deployment.Internal.Isolation.IEnumUnknown)hashElements._NewEnum;
                Marshal.ThrowExceptionForHR(unknown.Next(celt, rgelt, ref celtFetched));
                if (celtFetched != celt)
                {
                    throw new InvalidDeploymentException(ExceptionTypes.Manifest, Resources.GetString("Ex_IsoEnumFetchNotEqualToCount"));
                }
                for (uint i = 0; i < celt; i++)
                {
                    System.Deployment.Internal.Isolation.Manifest.HashElementEntry allData = rgelt[i].AllData;
                    if (allData.DigestValueSize > 0)
                    {
                        byte[] destination = new byte[allData.DigestValueSize];
                        Marshal.Copy(allData.DigestValue, destination, 0, (int)allData.DigestValueSize);
                        this._hashCollection.AddHash(destination, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD)allData.DigestMethod, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM)allData.Transform);
                        flag = true;
                    }
                }
            }
            if (!flag && (dependentAssembly.HashValueSize > 0))
            {
                byte[] buffer2 = new byte[dependentAssembly.HashValueSize];
                Marshal.Copy(dependentAssembly.HashValue, buffer2, 0, (int)dependentAssembly.HashValueSize);
                this._hashCollection.AddHash(buffer2, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD)dependentAssembly.HashAlgorithm, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY);
            }
            this._preRequisite = (dependentAssembly.Flags & 4) != 0;
            this._optional     = (assemblyReferenceEntry.Flags & 1) != 0;
            this._visible      = (dependentAssembly.Flags & 2) != 0;
            this._resourceFallbackCultureInternal = (dependentAssembly.Flags & 8) != 0;
            this._resourceFallbackCulture         = dependentAssembly.ResourceFallbackCulture;
            this._description = dependentAssembly.Description;
            this._supportUrl  = AssemblyManifest.UriFromMetadataEntry(dependentAssembly.SupportUrl, "Ex_DependencySupportUrlNotValid");
            System.Deployment.Internal.Isolation.IReferenceIdentity referenceIdentity = assemblyReferenceEntry.ReferenceIdentity;
            this._identity   = new System.Deployment.Application.ReferenceIdentity(referenceIdentity);
            this._codebaseFS = UriHelper.NormalizePathDirectorySeparators(this._codebase);
        }
 internal static System.Deployment.Application.DefinitionIdentity GetDefinitionIdentityFromManagedAssembly(string filePath)
 {
     Guid guidOfType = System.Deployment.Internal.Isolation.IsolationInterop.GetGuidOfType(typeof(System.Deployment.Internal.Isolation.IReferenceIdentity));
     System.Deployment.Internal.Isolation.IReferenceIdentity assemblyIdentityFromFile = (System.Deployment.Internal.Isolation.IReferenceIdentity) System.Deployment.Application.NativeMethods.GetAssemblyIdentityFromFile(filePath, ref guidOfType);
     System.Deployment.Application.ReferenceIdentity refId = new System.Deployment.Application.ReferenceIdentity(assemblyIdentityFromFile);
     string processorArchitecture = refId.ProcessorArchitecture;
     if (processorArchitecture != null)
     {
         refId.ProcessorArchitecture = processorArchitecture.ToLower(CultureInfo.InvariantCulture);
     }
     System.Deployment.Application.DefinitionIdentity identity3 = new System.Deployment.Application.DefinitionIdentity(refId);
     Logger.AddInternalState("Managed Assembly Identity = " + identity3.ToString());
     return identity3;
 }
 public DependentAssembly(System.Deployment.Internal.Isolation.Manifest.AssemblyReferenceEntry assemblyReferenceEntry)
 {
     this._hashCollection = new System.Deployment.Application.HashCollection();
     System.Deployment.Internal.Isolation.Manifest.AssemblyReferenceDependentAssemblyEntry dependentAssembly = assemblyReferenceEntry.DependentAssembly;
     this._size = dependentAssembly.Size;
     this._codebase = dependentAssembly.Codebase;
     this._group = dependentAssembly.Group;
     bool flag = false;
     System.Deployment.Internal.Isolation.ISection hashElements = dependentAssembly.HashElements;
     uint celt = (hashElements != null) ? hashElements.Count : 0;
     if (celt > 0)
     {
         uint celtFetched = 0;
         System.Deployment.Internal.Isolation.Manifest.IHashElementEntry[] rgelt = new System.Deployment.Internal.Isolation.Manifest.IHashElementEntry[celt];
         System.Deployment.Internal.Isolation.IEnumUnknown unknown = (System.Deployment.Internal.Isolation.IEnumUnknown) hashElements._NewEnum;
         Marshal.ThrowExceptionForHR(unknown.Next(celt, rgelt, ref celtFetched));
         if (celtFetched != celt)
         {
             throw new InvalidDeploymentException(ExceptionTypes.Manifest, Resources.GetString("Ex_IsoEnumFetchNotEqualToCount"));
         }
         for (uint i = 0; i < celt; i++)
         {
             System.Deployment.Internal.Isolation.Manifest.HashElementEntry allData = rgelt[i].AllData;
             if (allData.DigestValueSize > 0)
             {
                 byte[] destination = new byte[allData.DigestValueSize];
                 Marshal.Copy(allData.DigestValue, destination, 0, (int) allData.DigestValueSize);
                 this._hashCollection.AddHash(destination, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD) allData.DigestMethod, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM) allData.Transform);
                 flag = true;
             }
         }
     }
     if (!flag && (dependentAssembly.HashValueSize > 0))
     {
         byte[] buffer2 = new byte[dependentAssembly.HashValueSize];
         Marshal.Copy(dependentAssembly.HashValue, buffer2, 0, (int) dependentAssembly.HashValueSize);
         this._hashCollection.AddHash(buffer2, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD) dependentAssembly.HashAlgorithm, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY);
     }
     this._preRequisite = (dependentAssembly.Flags & 4) != 0;
     this._optional = (assemblyReferenceEntry.Flags & 1) != 0;
     this._visible = (dependentAssembly.Flags & 2) != 0;
     this._resourceFallbackCultureInternal = (dependentAssembly.Flags & 8) != 0;
     this._resourceFallbackCulture = dependentAssembly.ResourceFallbackCulture;
     this._description = dependentAssembly.Description;
     this._supportUrl = AssemblyManifest.UriFromMetadataEntry(dependentAssembly.SupportUrl, "Ex_DependencySupportUrlNotValid");
     System.Deployment.Internal.Isolation.IReferenceIdentity referenceIdentity = assemblyReferenceEntry.ReferenceIdentity;
     this._identity = new System.Deployment.Application.ReferenceIdentity(referenceIdentity);
     this._codebaseFS = UriHelper.NormalizePathDirectorySeparators(this._codebase);
 }
Пример #9
0
        public static void GenerateGACDetectionManifest(ReferenceIdentity refId, string outputManifest)
        {
            XmlDocument document = ManifestGenerator.CloneAssemblyTemplate();

            if (ManifestGenerator.GACDetectionTempManifestAsmId == null)
            {
                Interlocked.CompareExchange(ref ManifestGenerator.GACDetectionTempManifestAsmId, (object)new DefinitionIdentity("GACDetectionTempManifest, version=1.0.0.0, type=win32"), (object)null);
            }
            ManifestGenerator.InjectIdentityXml(document, (DefinitionIdentity)ManifestGenerator.GACDetectionTempManifestAsmId);
            ManifestGenerator.AddDependencies(document, new DependentAssembly[1]
            {
                new DependentAssembly(refId)
            });
            using (FileStream fileStream = System.IO.File.Open(outputManifest, FileMode.CreateNew, FileAccess.Write))
                document.Save((Stream)fileStream);
        }
        internal static System.Deployment.Application.DefinitionIdentity GetDefinitionIdentityFromManagedAssembly(string filePath)
        {
            Guid guidOfType = System.Deployment.Internal.Isolation.IsolationInterop.GetGuidOfType(typeof(System.Deployment.Internal.Isolation.IReferenceIdentity));

            System.Deployment.Internal.Isolation.IReferenceIdentity assemblyIdentityFromFile = (System.Deployment.Internal.Isolation.IReferenceIdentity)System.Deployment.Application.NativeMethods.GetAssemblyIdentityFromFile(filePath, ref guidOfType);
            System.Deployment.Application.ReferenceIdentity         refId = new System.Deployment.Application.ReferenceIdentity(assemblyIdentityFromFile);
            string processorArchitecture = refId.ProcessorArchitecture;

            if (processorArchitecture != null)
            {
                refId.ProcessorArchitecture = processorArchitecture.ToLower(CultureInfo.InvariantCulture);
            }
            System.Deployment.Application.DefinitionIdentity identity3 = new System.Deployment.Application.DefinitionIdentity(refId);
            Logger.AddInternalState("Managed Assembly Identity = " + identity3.ToString());
            return(identity3);
        }
Пример #11
0
 public static bool VerifyGACDependencyXP(ReferenceIdentity refId, string tempDir)
 {
     if (!PlatformSpecific.OnXPOrAbove)
     {
         return(false);
     }
     using (TempFile tempFile = new TempFile(tempDir, ".manifest"))
     {
         ManifestGenerator.GenerateGACDetectionManifest(refId, tempFile.Path);
         IntPtr actCtxW = NativeMethods.CreateActCtxW(new NativeMethods.ACTCTXW(tempFile.Path));
         if (!(actCtxW != NativeMethods.INVALID_HANDLE_VALUE))
         {
             return(false);
         }
         NativeMethods.ReleaseActCtx(actCtxW);
         return(true);
     }
 }
Пример #12
0
 public static bool VerifyGACDependencyXP(ReferenceIdentity refId, string tempDir)
 {
     if (!PlatformSpecific.OnXPOrAbove)
     {
         return(false);
     }
     using (TempFile file = new TempFile(tempDir, ".manifest"))
     {
         ManifestGenerator.GenerateGACDetectionManifest(refId, file.Path);
         System.Deployment.Application.NativeMethods.ACTCTXW actCtx = new System.Deployment.Application.NativeMethods.ACTCTXW(file.Path);
         IntPtr hActCtx = System.Deployment.Application.NativeMethods.CreateActCtxW(actCtx);
         if (hActCtx != System.Deployment.Application.NativeMethods.INVALID_HANDLE_VALUE)
         {
             System.Deployment.Application.NativeMethods.ReleaseActCtx(hActCtx);
             return(true);
         }
         return(false);
     }
 }
Пример #13
0
        public static DefinitionIdentity GenerateManifest(ReferenceIdentity suggestedReferenceIdentity, AssemblyManifest manifest, string outputManifest)
        {
            DefinitionIdentity asmId = manifest.Identity;

            if (manifest.RawXmlBytes != null)
            {
                using (FileStream fileStream = System.IO.File.Open(outputManifest, FileMode.CreateNew, FileAccess.Write))
                    fileStream.Write(manifest.RawXmlBytes, 0, manifest.RawXmlBytes.Length);
            }
            else
            {
                XmlDocument document = ManifestGenerator.CloneAssemblyTemplate();
                asmId = new DefinitionIdentity(suggestedReferenceIdentity);
                ManifestGenerator.InjectIdentityXml(document, asmId);
                ManifestGenerator.AddFiles(document, manifest.Files);
                ManifestGenerator.AddDependencies(document, manifest.DependentAssemblies);
                using (FileStream fileStream = System.IO.File.Open(outputManifest, FileMode.CreateNew, FileAccess.Write))
                    document.Save((Stream)fileStream);
            }
            return(asmId);
        }
Пример #14
0
        private static void AddDependencies(XmlDocument document, DependentAssembly[] dependentAssemblies)
        {
            Hashtable           hashtable    = new Hashtable();
            XmlNamespaceManager namespaceMgr = ManifestGenerator.GetNamespaceMgr(document);
            XmlElement          xmlElement   = (XmlElement)document.SelectSingleNode("/asmv1:assembly", namespaceMgr);

            foreach (DependentAssembly dependentAssembly in dependentAssemblies)
            {
                if (!hashtable.Contains((object)dependentAssembly.Identity))
                {
                    XmlElement element1 = document.CreateElement("dependency", "urn:schemas-microsoft-com:asm.v1");
                    xmlElement.AppendChild((XmlNode)element1);
                    XmlElement element2 = document.CreateElement("dependentAssembly", "urn:schemas-microsoft-com:asm.v1");
                    element1.AppendChild((XmlNode)element2);
                    ReferenceIdentity  identity = dependentAssembly.Identity;
                    DefinitionIdentity asmId    = new DefinitionIdentity(identity);
                    XmlElement         assemblyIdentityElement = ManifestGenerator.CreateAssemblyIdentityElement(document, asmId);
                    element2.AppendChild((XmlNode)assemblyIdentityElement);
                    hashtable.Add((object)identity, (object)asmId);
                }
            }
        }
Пример #15
0
 public static bool VerifyGACDependency(NativeMethods.IAssemblyCache AssemblyCache, bool targetOtherClr, NativeMethods.CCorRuntimeHost RuntimeHost, ReferenceIdentity refId, string tempDir)
 {
     if (string.Compare(refId.ProcessorArchitecture, "msil", StringComparison.OrdinalIgnoreCase) == 0 || !PlatformDetector.VerifyGACDependencyXP(refId, tempDir))
     {
         return(PlatformDetector.VerifyGACDependencyWhidbey(AssemblyCache, targetOtherClr, RuntimeHost, refId));
     }
     return(true);
 }
 public DependentAssembly(System.Deployment.Application.ReferenceIdentity refId)
 {
     this._hashCollection = new System.Deployment.Application.HashCollection();
     this._identity = refId;
 }
Пример #17
0
 public static bool VerifyGACDependency(System.Deployment.Application.NativeMethods.IAssemblyCache AssemblyCache, bool targetOtherClr, System.Deployment.Application.NativeMethods.CCorRuntimeHost RuntimeHost, ReferenceIdentity refId, string tempDir)
 {
     if (string.Compare(refId.ProcessorArchitecture, "msil", StringComparison.OrdinalIgnoreCase) == 0)
     {
         return(VerifyGACDependencyWhidbey(AssemblyCache, targetOtherClr, RuntimeHost, refId));
     }
     if (!VerifyGACDependencyXP(refId, tempDir))
     {
         return(VerifyGACDependencyWhidbey(AssemblyCache, targetOtherClr, RuntimeHost, refId));
     }
     return(true);
 }
Пример #18
0
 public DependentAssembly(System.Deployment.Application.ReferenceIdentity refId)
 {
     this._hashCollection = new System.Deployment.Application.HashCollection();
     this._identity       = refId;
 }
Пример #19
0
 private static bool IsNetFX35SP1FullSignatureAsm(ReferenceIdentity ra)
 {
     return(new DefinitionIdentity("System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089,processorArchitecture=msil").Matches(ra, true));
 }
Пример #20
0
 private static bool IsNetFX35SP1ClientSignatureAsm(ReferenceIdentity ra)
 {
     return(new DefinitionIdentity("Sentinel.v3.5Client, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,processorArchitecture=msil").Matches(ra, true));
 }
Пример #21
0
        public static void VerifyPlatformDependencies(AssemblyManifest appManifest, AssemblyManifest deployManifest, string tempDir)
        {
            Logger.AddMethodCall("VerifyPlatformDependencies called.");
            string      str1        = (string)null;
            Uri         supportUrl1 = deployManifest.Description.SupportUri;
            bool        flag1       = false;
            DependentOS dependentOs = appManifest.DependentOS;

            if (dependentOs != null)
            {
                PlatformDetector.OSDependency osd = new PlatformDetector.OSDependency((uint)dependentOs.MajorVersion, (uint)dependentOs.MinorVersion, (uint)dependentOs.BuildNumber, (ushort)dependentOs.ServicePackMajor, (ushort)dependentOs.ServicePackMinor, (string)null, (string)null);
                if (!PlatformDetector.VerifyOSDependency(ref osd))
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    string        str2          = ((int)dependentOs.MajorVersion).ToString() + "." + (object)dependentOs.MinorVersion + "." + (object)dependentOs.BuildNumber + "." + (object)dependentOs.ServicePackMajor + (object)dependentOs.ServicePackMinor;
                    stringBuilder.AppendFormat(Resources.GetString("PlatformMicrosoftWindowsOperatingSystem"), (object)str2);
                    string str3 = stringBuilder.ToString();
                    if (dependentOs.SupportUrl != (Uri)null)
                    {
                        supportUrl1 = dependentOs.SupportUrl;
                    }
                    throw new DependentPlatformMissingException(string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_PlatformDetectionFailed"), new object[1] {
                        (object)str3
                    }), supportUrl1);
                }
            }
            if (PlatformDetector.IsWin8orLater() && !appManifest.EntryPoints[0].HostInBrowser)
            {
                flag1 = true;
            }
            Version clrVersion            = Constants.V2CLRVersion;
            string  clrVersionString      = clrVersion.ToString(3);
            string  processorArchitecture = appManifest.Identity.ProcessorArchitecture;
            Uri     supportUrl2           = supportUrl1;

            if (appManifest.CLRDependentAssembly != null)
            {
                clrVersion            = appManifest.CLRDependentAssembly.Identity.Version;
                clrVersionString      = clrVersion.ToString(3);
                processorArchitecture = appManifest.CLRDependentAssembly.Identity.ProcessorArchitecture;
                if (appManifest.CLRDependentAssembly.SupportUrl != (Uri)null)
                {
                    supportUrl2 = appManifest.CLRDependentAssembly.SupportUrl;
                }
                if (appManifest.CLRDependentAssembly.Description != null)
                {
                    str1 = appManifest.CLRDependentAssembly.Description;
                }
            }
            if (deployManifest.CompatibleFrameworks != null)
            {
                bool flag2 = false;
                for (int index = 0; index < deployManifest.CompatibleFrameworks.Frameworks.Count; ++index)
                {
                    if (PlatformDetector.CheckCompatibleFramework(deployManifest.CompatibleFrameworks.Frameworks[index], ref clrVersion, ref clrVersionString, processorArchitecture))
                    {
                        flag2 = true;
                        break;
                    }
                }
                if (!flag2)
                {
                    Uri supportUrl3 = !(deployManifest.CompatibleFrameworks.SupportUrl != (Uri)null) ? supportUrl2 : deployManifest.CompatibleFrameworks.SupportUrl;
                    if (flag1)
                    {
                        return;
                    }
                    throw new CompatibleFrameworkMissingException(string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_CompatiblePlatformDetectionFailed"), new object[1]
                    {
                        (object)PlatformDetector.FormatFrameworkString(deployManifest.CompatibleFrameworks.Frameworks[0])
                    }), supportUrl3, deployManifest.CompatibleFrameworks);
                }
            }
            else
            {
                if (clrVersion >= Constants.V4CLRVersion)
                {
                    throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_SemanticallyInvalidDeploymentManifest"), (Exception) new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_DepMissingCompatibleFrameworks")));
                }
                if (!NativeMethods.VerifyCLRVersionInfo(clrVersion, processorArchitecture))
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    if (str1 == null)
                    {
                        stringBuilder.AppendFormat(Resources.GetString("PlatformMicrosoftCommonLanguageRuntime"), (object)clrVersionString);
                        str1 = stringBuilder.ToString();
                    }
                    Uri supportUrl3 = supportUrl2;
                    if (flag1)
                    {
                        return;
                    }
                    throw new SupportedRuntimeMissingException(string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_PlatformDetectionFailed"), new object[1] {
                        (object)str1
                    }), supportUrl3, clrVersionString);
                }
            }
            Logger.AddPhaseInformation(Resources.GetString("CompatibleRuntimeFound"), new object[1]
            {
                (object)clrVersionString
            });
            bool flag3 = false;

            if (clrVersion < Constants.V4CLRVersion)
            {
                flag3 = true;
            }
            NativeMethods.CCorRuntimeHost RuntimeHost = (NativeMethods.CCorRuntimeHost)null;
            try
            {
                NativeMethods.IAssemblyCache assemblyCacheInterface = NativeMethods.GetAssemblyCacheInterface(clrVersionString, flag3, out RuntimeHost);
                if (assemblyCacheInterface == null || flag3 && RuntimeHost == null)
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.AppendFormat(Resources.GetString("PlatformMicrosoftCommonLanguageRuntime"), (object)clrVersionString);
                    throw new DependentPlatformMissingException(string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_PlatformDetectionFailed"), new object[1]
                    {
                        (object)stringBuilder.ToString()
                    }), supportUrl2);
                }
                bool flag2 = false;
                bool flag4 = false;
                if (flag3 && !PolicyKeys.SkipSKUDetection())
                {
                    foreach (DependentAssembly dependentAssembly in appManifest.DependentAssemblies)
                    {
                        if (dependentAssembly.IsPreRequisite && PlatformDetector.IsNetFX35SP1ClientSignatureAsm(dependentAssembly.Identity))
                        {
                            flag2 = true;
                        }
                        if (dependentAssembly.IsPreRequisite && PlatformDetector.IsNetFX35SP1FullSignatureAsm(dependentAssembly.Identity))
                        {
                            flag4 = true;
                        }
                    }
                    if (PlatformDetector.GetPlatformNetFx35SKU(assemblyCacheInterface, flag3, RuntimeHost, tempDir) == PlatformDetector.NetFX35SP1SKU.Client35SP1 && !flag2 && !flag4)
                    {
                        throw new DependentPlatformMissingException(string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_PlatformDetectionFailed"), new object[1]
                        {
                            (object)".NET Framework 3.5 SP1"
                        }));
                    }
                }
                foreach (DependentAssembly dependentAssembly in appManifest.DependentAssemblies)
                {
                    if (dependentAssembly.IsPreRequisite && !PlatformDetector.IsCLRDependencyText(dependentAssembly.Identity.Name))
                    {
                        if (!flag3 && (PlatformDetector.IsNetFX35SP1ClientSignatureAsm(dependentAssembly.Identity) || PlatformDetector.IsNetFX35SP1FullSignatureAsm(dependentAssembly.Identity) || "framework".Equals(dependentAssembly.Group, StringComparison.OrdinalIgnoreCase)))
                        {
                            Logger.AddPhaseInformation(Resources.GetString("SkippingSentinalDependentAssembly"), new object[1]
                            {
                                (object)dependentAssembly.Identity.ToString()
                            });
                        }
                        else if (!PlatformDetector.VerifyGACDependency(assemblyCacheInterface, flag3, RuntimeHost, dependentAssembly.Identity, tempDir))
                        {
                            string description;
                            if (dependentAssembly.Description != null)
                            {
                                description = dependentAssembly.Description;
                            }
                            else
                            {
                                ReferenceIdentity identity      = dependentAssembly.Identity;
                                StringBuilder     stringBuilder = new StringBuilder();
                                stringBuilder.AppendFormat(Resources.GetString("PlatformDependentAssemblyVersion"), (object)identity.Name, (object)identity.Version);
                                description = stringBuilder.ToString();
                            }
                            if (dependentAssembly.SupportUrl != (Uri)null)
                            {
                                supportUrl1 = dependentAssembly.SupportUrl;
                            }
                            throw new DependentPlatformMissingException(string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_PlatformGACDetectionFailed"), new object[1]
                            {
                                (object)description
                            }), supportUrl1);
                        }
                    }
                }
            }
            finally
            {
                if (RuntimeHost != null)
                {
                    RuntimeHost.Dispose();
                }
            }
        }
Пример #22
0
        public static void VerifyPlatformDependencies(AssemblyManifest appManifest, AssemblyManifest deployManifest, string tempDir)
        {
            Logger.AddMethodCall("VerifyPlatformDependencies called.");
            string      description = null;
            Uri         supportUri  = deployManifest.Description.SupportUri;
            DependentOS dependentOS = appManifest.DependentOS;

            if (dependentOS != null)
            {
                OSDependency osd = new OSDependency(dependentOS.MajorVersion, dependentOS.MinorVersion, dependentOS.BuildNumber, dependentOS.ServicePackMajor, dependentOS.ServicePackMinor, null, null);
                if (!VerifyOSDependency(ref osd))
                {
                    StringBuilder builder = new StringBuilder();
                    string        str2    = string.Concat(new object[] { dependentOS.MajorVersion, ".", dependentOS.MinorVersion, ".", dependentOS.BuildNumber, ".", dependentOS.ServicePackMajor, dependentOS.ServicePackMinor });
                    builder.AppendFormat(Resources.GetString("PlatformMicrosoftWindowsOperatingSystem"), str2);
                    description = builder.ToString();
                    if (dependentOS.SupportUrl != null)
                    {
                        supportUri = dependentOS.SupportUrl;
                    }
                    throw new DependentPlatformMissingException(string.Format(CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_PlatformDetectionFailed"), new object[] { description }), supportUri);
                }
            }
            Version v    = Constants.V2CLRVersion;
            string  str3 = v.ToString(3);
            string  processorArchitecture = appManifest.Identity.ProcessorArchitecture;
            Uri     supportUrl            = supportUri;

            if (appManifest.CLRDependentAssembly != null)
            {
                v    = appManifest.CLRDependentAssembly.Identity.Version;
                str3 = v.ToString(3);
                processorArchitecture = appManifest.CLRDependentAssembly.Identity.ProcessorArchitecture;
                if (appManifest.CLRDependentAssembly.SupportUrl != null)
                {
                    supportUrl = appManifest.CLRDependentAssembly.SupportUrl;
                }
                if (appManifest.CLRDependentAssembly.Description != null)
                {
                    description = appManifest.CLRDependentAssembly.Description;
                }
            }
            if (deployManifest.CompatibleFrameworks == null)
            {
                if (v >= Constants.V4CLRVersion)
                {
                    throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_SemanticallyInvalidDeploymentManifest"), new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_DepMissingCompatibleFrameworks")));
                }
                if (!VerifyCLRVersionInfo(v, processorArchitecture))
                {
                    StringBuilder builder2 = new StringBuilder();
                    if (description == null)
                    {
                        builder2.AppendFormat(Resources.GetString("PlatformMicrosoftCommonLanguageRuntime"), str3);
                        description = builder2.ToString();
                    }
                    supportUri = supportUrl;
                    throw new SupportedRuntimeMissingException(string.Format(CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_PlatformDetectionFailed"), new object[] { description }), supportUri, str3);
                }
            }
            else
            {
                bool flag = false;
                for (int i = 0; i < deployManifest.CompatibleFrameworks.Frameworks.Count; i++)
                {
                    if (CheckCompatibleFramework(deployManifest.CompatibleFrameworks.Frameworks[i], ref v, ref str3, processorArchitecture))
                    {
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    if (deployManifest.CompatibleFrameworks.SupportUrl != null)
                    {
                        supportUri = deployManifest.CompatibleFrameworks.SupportUrl;
                    }
                    else
                    {
                        supportUri = supportUrl;
                    }
                    throw new CompatibleFrameworkMissingException(string.Format(CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_CompatiblePlatformDetectionFailed"), new object[] { FormatFrameworkString(deployManifest.CompatibleFrameworks.Frameworks[0]) }), supportUri, deployManifest.CompatibleFrameworks);
                }
            }
            Logger.AddPhaseInformation(Resources.GetString("CompatibleRuntimeFound"), new object[] { str3 });
            bool fetchRuntimeHost = false;

            if (v < Constants.V4CLRVersion)
            {
                fetchRuntimeHost = true;
            }
            using (System.Deployment.Application.NativeMethods.CCorRuntimeHost host = null)
            {
                System.Deployment.Application.NativeMethods.IAssemblyCache assemblyCache = System.Deployment.Application.NativeMethods.GetAssemblyCacheInterface(str3, fetchRuntimeHost, out host);
                if ((assemblyCache == null) || (fetchRuntimeHost && (host == null)))
                {
                    StringBuilder builder3 = new StringBuilder();
                    builder3.AppendFormat(Resources.GetString("PlatformMicrosoftCommonLanguageRuntime"), str3);
                    description = builder3.ToString();
                    supportUri  = supportUrl;
                    throw new DependentPlatformMissingException(string.Format(CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_PlatformDetectionFailed"), new object[] { description }), supportUri);
                }
                bool flag3 = false;
                bool flag4 = false;
                if (fetchRuntimeHost && !PolicyKeys.SkipSKUDetection())
                {
                    foreach (DependentAssembly assembly in appManifest.DependentAssemblies)
                    {
                        if (assembly.IsPreRequisite && IsNetFX35SP1ClientSignatureAsm(assembly.Identity))
                        {
                            flag3 = true;
                        }
                        if (assembly.IsPreRequisite && IsNetFX35SP1FullSignatureAsm(assembly.Identity))
                        {
                            flag4 = true;
                        }
                    }
                    if (((GetPlatformNetFx35SKU(assemblyCache, fetchRuntimeHost, host, tempDir) == NetFX35SP1SKU.Client35SP1) && !flag3) && !flag4)
                    {
                        description = ".NET Framework 3.5 SP1";
                        throw new DependentPlatformMissingException(string.Format(CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_PlatformDetectionFailed"), new object[] { description }));
                    }
                }
                foreach (DependentAssembly assembly2 in appManifest.DependentAssemblies)
                {
                    if (assembly2.IsPreRequisite && !IsCLRDependencyText(assembly2.Identity.Name))
                    {
                        if (!fetchRuntimeHost && ((IsNetFX35SP1ClientSignatureAsm(assembly2.Identity) || IsNetFX35SP1FullSignatureAsm(assembly2.Identity)) || "framework".Equals(assembly2.Group, StringComparison.OrdinalIgnoreCase)))
                        {
                            Logger.AddPhaseInformation(Resources.GetString("SkippingSentinalDependentAssembly"), new object[] { assembly2.Identity.ToString() });
                        }
                        else if (!VerifyGACDependency(assemblyCache, fetchRuntimeHost, host, assembly2.Identity, tempDir))
                        {
                            if (assembly2.Description != null)
                            {
                                description = assembly2.Description;
                            }
                            else
                            {
                                ReferenceIdentity identity = assembly2.Identity;
                                StringBuilder     builder4 = new StringBuilder();
                                builder4.AppendFormat(Resources.GetString("PlatformDependentAssemblyVersion"), identity.Name, identity.Version);
                                description = builder4.ToString();
                            }
                            if (assembly2.SupportUrl != null)
                            {
                                supportUri = assembly2.SupportUrl;
                            }
                            throw new DependentPlatformMissingException(string.Format(CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_PlatformGACDetectionFailed"), new object[] { description }), supportUri);
                        }
                    }
                }
            }
        }