public EntryPoint(System.Deployment.Internal.Isolation.Manifest.EntryPointEntry entryPointEntry, AssemblyManifest manifest)
 {
     this._name = entryPointEntry.Name;
     this._commandLineFile = entryPointEntry.CommandLine_File;
     this._commandLineParamater = entryPointEntry.CommandLine_Parameters;
     this._hostInBrowser = (entryPointEntry.Flags & 1) != 0;
     this._customHostSpecified = (entryPointEntry.Flags & 2) != 0;
     this._customUX = (entryPointEntry.Flags & 4) != 0;
     if (!this._customHostSpecified)
     {
         if (entryPointEntry.Identity != null)
         {
             this._dependentAssembly = manifest.GetDependentAssemblyByIdentity(entryPointEntry.Identity);
         }
         if (this._dependentAssembly == null)
         {
             throw new InvalidDeploymentException(ExceptionTypes.ManifestParse, Resources.GetString("Ex_NoMatchingAssemblyForEntryPoint"));
         }
     }
 }
 public EntryPoint(System.Deployment.Internal.Isolation.Manifest.EntryPointEntry entryPointEntry, AssemblyManifest manifest)
 {
     this._name                 = entryPointEntry.Name;
     this._commandLineFile      = entryPointEntry.CommandLine_File;
     this._commandLineParamater = entryPointEntry.CommandLine_Parameters;
     this._hostInBrowser        = (entryPointEntry.Flags & 1) != 0;
     this._customHostSpecified  = (entryPointEntry.Flags & 2) != 0;
     this._customUX             = (entryPointEntry.Flags & 4) != 0;
     if (!this._customHostSpecified)
     {
         if (entryPointEntry.Identity != null)
         {
             this._dependentAssembly = manifest.GetDependentAssemblyByIdentity(entryPointEntry.Identity);
         }
         if (this._dependentAssembly == null)
         {
             throw new InvalidDeploymentException(ExceptionTypes.ManifestParse, Resources.GetString("Ex_NoMatchingAssemblyForEntryPoint"));
         }
     }
 }
 private static void AddDependencies(XmlDocument document, DependentAssembly[] dependentAssemblies)
 {
     Hashtable hashtable = new Hashtable();
     XmlNamespaceManager namespaceMgr = GetNamespaceMgr(document);
     XmlElement element = (XmlElement) document.SelectSingleNode("/asmv1:assembly", namespaceMgr);
     foreach (DependentAssembly assembly in dependentAssemblies)
     {
         if (!hashtable.Contains(assembly.Identity))
         {
             XmlElement newChild = document.CreateElement("dependency", "urn:schemas-microsoft-com:asm.v1");
             element.AppendChild(newChild);
             XmlElement element3 = document.CreateElement("dependentAssembly", "urn:schemas-microsoft-com:asm.v1");
             newChild.AppendChild(element3);
             System.Deployment.Application.ReferenceIdentity refId = assembly.Identity;
             System.Deployment.Application.DefinitionIdentity asmId = new System.Deployment.Application.DefinitionIdentity(refId);
             XmlElement element4 = CreateAssemblyIdentityElement(document, asmId);
             element3.AppendChild(element4);
             hashtable.Add(refId, asmId);
         }
     }
 }
 internal void ValidateSemanticsForApplicationRole()
 {
     try
     {
         ValidateAssemblyIdentity(this.Identity);
         if (this.EntryPoints.Length != 1)
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_AppOneEntryPoint"));
         }
         EntryPoint point = this.EntryPoints[0];
         if (!point.CustomHostSpecified && ((((point.Assembly == null) || point.Assembly.IsOptional) || (point.Assembly.IsPreRequisite || (point.Assembly.Codebase == null))) || (((!UriHelper.IsValidRelativeFilePath(point.Assembly.Codebase) || UriHelper.PathContainDirectorySeparators(point.Assembly.Codebase)) || (!UriHelper.IsValidRelativeFilePath(point.CommandFile) || UriHelper.PathContainDirectorySeparators(point.CommandFile))) || (!point.CommandFile.Equals(point.Assembly.Codebase, StringComparison.OrdinalIgnoreCase) || (string.Compare(this.Identity.ProcessorArchitecture, point.Assembly.Identity.ProcessorArchitecture, StringComparison.OrdinalIgnoreCase) != 0)))))
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_AppInvalidEntryPoint"));
         }
         if (this.Application && (point.CommandParameters != null))
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_AppInvalidEntryPointParameters"));
         }
         if ((this.DependentAssemblies == null) || (this.DependentAssemblies.Length == 0))
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_AppAtLeastOneDependency"));
         }
         if (this.Deployment != null)
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_AppNoDeploymentAllowed"));
         }
         if (this.CompatibleFrameworks != null)
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_AppNoCompatibleFrameworksAllowed"));
         }
         if (this.UseManifestForTrust)
         {
             if ((this.Description == null) || ((this.Description != null) && ((this.Description.Publisher == null) || (this.Description.Product == null))))
             {
                 throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_AppNoOverridePublisherProduct"));
             }
         }
         else if ((this.Description != null) && ((this.Description.Publisher != null) || (this.Description.Product != null)))
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_AppNoPublisherProductAllowed"));
         }
         if (((this.Description != null) && (this.Description.IconFile != null)) && !UriHelper.IsValidRelativeFilePath(this.Description.IconFile))
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_AppInvalidIconFile"));
         }
         if ((this.Description != null) && (this.Description.SupportUri != null))
         {
             if (!this.Description.SupportUri.IsAbsoluteUri)
             {
                 throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_DescriptionSupportUrlNotAbsolute"));
             }
             if (!UriHelper.IsSupportedScheme(this.Description.SupportUri))
             {
                 throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_DescriptionSupportUrlNotSupportedUriScheme"));
             }
             if (this.Description.SupportUri.AbsoluteUri.Length > 0x4000)
             {
                 throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_DescriptionSupportUrlTooLong"));
             }
         }
         if (this.Files.Length > 0x6000)
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_TooManyFilesInManifest"));
         }
         Hashtable hashtable = new Hashtable();
         foreach (System.Deployment.Application.Manifest.File file in this.Files)
         {
             ValidateFile(file);
             if (!file.IsOptional && !hashtable.Contains(file.Name))
             {
                 hashtable.Add(file.Name.ToLower(), file);
             }
             if (file.HashCollection.Count == 0)
             {
                 this._unhashedFilePresent = true;
             }
         }
         if ((this.FileAssociations.Length > 0) && point.HostInBrowser)
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_FileAssociationNotSupportedForHostInBrowser"));
         }
         if ((this.FileAssociations.Length > 0) && point.CustomHostSpecified)
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_FileAssociationNotSupportedForCustomHost"));
         }
         if (this.FileAssociations.Length > 8)
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_TooManyFileAssociationsInManifest"), new object[] { 8 }));
         }
         Hashtable hashtable2 = new Hashtable();
         foreach (FileAssociation association in this.FileAssociations)
         {
             if ((string.IsNullOrEmpty(association.Extension) || string.IsNullOrEmpty(association.Description)) || (string.IsNullOrEmpty(association.ProgID) || string.IsNullOrEmpty(association.DefaultIcon)))
             {
                 throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_FileExtensionInfoMissing"));
             }
             if (association.Extension.Length > 0)
             {
                 char ch = association.Extension[0];
                 if (ch != '.')
                 {
                     throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_FileAssociationExtensionNoDot"), new object[] { association.Extension }));
                 }
             }
             if (!UriHelper.IsValidRelativeFilePath("file" + association.Extension))
             {
                 throw new InvalidDeploymentException(ExceptionTypes.ManifestComponentSemanticValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_FileAssociationInvalid"), new object[] { association.Extension }));
             }
             if (association.Extension.Length > 0x18)
             {
                 throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_FileExtensionTooLong"), new object[] { association.Extension }));
             }
             if (!hashtable.Contains(association.DefaultIcon.ToLower()))
             {
                 throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_FileAssociationIconFileNotFound"), new object[] { association.DefaultIcon }));
             }
             if (hashtable2.Contains(association.Extension))
             {
                 throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_MultipleInstanceFileExtension"), new object[] { association.Extension }));
             }
             hashtable2.Add(association.Extension, association);
         }
         if (this.DependentAssemblies.Length > 0x6000)
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_TooManyAssembliesInManifest"));
         }
         bool flag = false;
         foreach (DependentAssembly assembly in this.DependentAssemblies)
         {
             ValidateComponentDependency(assembly);
             if (assembly.IsPreRequisite && PlatformDetector.IsCLRDependencyText(assembly.Identity.Name))
             {
                 flag = true;
                 this._clrDependentAssembly = assembly;
             }
             if (!assembly.IsPreRequisite && (assembly.HashCollection.Count == 0))
             {
                 this._unhashedDependencyPresent = true;
             }
         }
         this._clrDependentAssemblyChecked = true;
         if ((this.DependentOS != null) && (this.DependentOS.SupportUrl != null))
         {
             if (!this.DependentOS.SupportUrl.IsAbsoluteUri)
             {
                 throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_DepenedentOSSupportUrlNotAbsolute"));
             }
             if (!UriHelper.IsSupportedScheme(this.DependentOS.SupportUrl))
             {
                 throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_DepenedentOSSupportUrlNotSupportedUriScheme"));
             }
             if (this.DependentOS.SupportUrl.AbsoluteUri.Length > 0x4000)
             {
                 throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_DepenedentOSSupportUrlTooLong"));
             }
         }
         if (!flag)
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_AppNoCLRDependency"), new object[0]));
         }
     }
     catch (InvalidDeploymentException exception)
     {
         throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_SemanticallyInvalidApplicationManifest"), exception);
     }
 }
 private static void ValidateComponentDependency(DependentAssembly da)
 {
     ValidateAssemblyIdentity(da.Identity);
     if (!da.IsPreRequisite)
     {
         if (da.ResourceFallbackCulture != null)
         {
             if (da.Identity.Culture != null)
             {
                 if (IsInvalidHash(da.HashCollection))
                 {
                     throw new InvalidDeploymentException(ExceptionTypes.ManifestComponentSemanticValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DependencyInvalidHash"), new object[] { da.Identity.ToString() }));
                 }
                 if (da.Codebase == null)
                 {
                     throw new InvalidDeploymentException(ExceptionTypes.ManifestComponentSemanticValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DependencyNoCodebase"), new object[] { da.Identity.ToString() }));
                 }
                 if (!UriHelper.IsValidRelativeFilePath(da.Codebase))
                 {
                     throw new InvalidDeploymentException(ExceptionTypes.ManifestComponentSemanticValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DependencyNotRelativePath"), new object[] { da.Identity.ToString() }));
                 }
                 if (da.ResourceFallbackCulture != null)
                 {
                     throw new InvalidDeploymentException(ExceptionTypes.ManifestComponentSemanticValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DependencyResourceWithFallback"), new object[] { da.Identity.ToString() }));
                 }
             }
             else
             {
                 if (da.Codebase != null)
                 {
                     throw new InvalidDeploymentException(ExceptionTypes.ManifestComponentSemanticValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DependencyResourceWithCodebase"), new object[] { da.Identity.ToString() }));
                 }
                 if (da.HashCollection.Count > 0)
                 {
                     throw new InvalidDeploymentException(ExceptionTypes.ManifestComponentSemanticValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DependencyResourceWithHash"), new object[] { da.Identity.ToString() }));
                 }
             }
         }
         else
         {
             if (IsInvalidHash(da.HashCollection))
             {
                 throw new InvalidDeploymentException(ExceptionTypes.ManifestComponentSemanticValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DependencyInvalidHash"), new object[] { da.Identity.ToString() }));
             }
             if (da.Codebase == null)
             {
                 throw new InvalidDeploymentException(ExceptionTypes.ManifestComponentSemanticValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DependencyNoCodebase"), new object[] { da.Identity.ToString() }));
             }
             if (!UriHelper.IsValidRelativeFilePath(da.Codebase))
             {
                 throw new InvalidDeploymentException(ExceptionTypes.ManifestComponentSemanticValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DependencyNotRelativePath"), new object[] { da.Identity.ToString() }));
             }
             if (da.IsOptional && (da.Group == null))
             {
                 throw new InvalidDeploymentException(ExceptionTypes.ManifestComponentSemanticValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DependencyOptionalButNoGroup"), new object[] { da.Identity.ToString() }));
             }
         }
     }
     else if (!PlatformDetector.IsCLRDependencyText(da.Identity.Name) && (da.Identity.PublicKeyToken == null))
     {
         throw new InvalidDeploymentException(ExceptionTypes.ManifestComponentSemanticValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DependencyGACNoPKT"), new object[] { da.Identity.ToString() }));
     }
     if (da.SupportUrl != null)
     {
         if (!da.SupportUrl.IsAbsoluteUri)
         {
             throw new InvalidDeploymentException(ExceptionTypes.ManifestComponentSemanticValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DependencySupportUrlNoAbsolute"), new object[] { da.Identity.ToString() }));
         }
         if (!UriHelper.IsSupportedScheme(da.SupportUrl))
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DependencySupportUrlNotSupportedUriScheme"), new object[] { da.Identity.ToString() }));
         }
         if (da.SupportUrl.AbsoluteUri.Length > 0x4000)
         {
             throw new InvalidDeploymentException(ExceptionTypes.ManifestComponentSemanticValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DependencySupportUrlTooLong"), new object[] { da.Identity.ToString() }));
         }
     }
 }
 private void ValidateApplicationDependency(DependentAssembly da)
 {
     ValidateAssemblyIdentity(da.Identity);
     if (da.Identity.PublicKeyToken == null)
     {
         throw new InvalidDeploymentException(ExceptionTypes.ManifestComponentSemanticValidation, Resources.GetString("Ex_DepAppRefNotStrongNamed"));
     }
     if (IsInvalidHash(da.HashCollection))
     {
         throw new InvalidDeploymentException(ExceptionTypes.ManifestComponentSemanticValidation, Resources.GetString("Ex_DepAppRefHashInvalid"));
     }
     if (string.Compare(this.Identity.ProcessorArchitecture, da.Identity.ProcessorArchitecture, StringComparison.OrdinalIgnoreCase) != 0)
     {
         throw new InvalidDeploymentException(ExceptionTypes.ManifestComponentSemanticValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DepAppRefProcArchMismatched"), new object[] { da.Identity.ProcessorArchitecture, this.Identity.ProcessorArchitecture }));
     }
     if (((da.ResourceFallbackCulture != null) || da.IsPreRequisite) || da.IsOptional)
     {
         throw new InvalidDeploymentException(ExceptionTypes.ManifestComponentSemanticValidation, Resources.GetString("Ex_DepAppRefPrereqOrOptionalOrResourceFallback"));
     }
     Uri uri = null;
     try
     {
         uri = new Uri(da.Codebase, UriKind.RelativeOrAbsolute);
     }
     catch (UriFormatException exception)
     {
         throw new InvalidDeploymentException(ExceptionTypes.ManifestComponentSemanticValidation, Resources.GetString("Ex_DepAppRefInvalidCodebaseUri"), exception);
     }
     if (uri.IsAbsoluteUri && !UriHelper.IsSupportedScheme(uri))
     {
         throw new InvalidDeploymentException(ExceptionTypes.ManifestComponentSemanticValidation, Resources.GetString("Ex_DepAppRefInvalidCodebaseUri"));
     }
     if (!UriHelper.IsValidRelativeFilePath(da.Identity.Name) || UriHelper.PathContainDirectorySeparators(da.Identity.Name))
     {
         throw new InvalidDeploymentException(ExceptionTypes.ManifestComponentSemanticValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DepAppRefInvalidIdentityName"), new object[] { da.Identity.Name }));
     }
 }
 private bool LoadFromCompLibAssembly(string filePath)
 {
     bool flag;
     try
     {
         using (AssemblyMetaDataImport import = new AssemblyMetaDataImport(filePath))
         {
             AssemblyName name = import.Name;
             this._identity = SystemUtils.GetDefinitionIdentityFromManagedAssembly(filePath);
             this._complibIdentity = (System.Deployment.Application.DefinitionIdentity) this.Identity.Clone();
             AssemblyModule[] files = import.Files;
             AssemblyReference[] references = import.References;
             System.Deployment.Application.Manifest.File[] fileArray = new System.Deployment.Application.Manifest.File[files.Length + 1];
             fileArray[0] = new System.Deployment.Application.Manifest.File(Path.GetFileName(filePath), 0L);
             for (int i = 0; i < files.Length; i++)
             {
                 fileArray[i + 1] = new System.Deployment.Application.Manifest.File(files[i].Name, files[i].Hash, 0L);
             }
             this._files = fileArray;
             DependentAssembly[] assemblyArray = new DependentAssembly[references.Length];
             for (int j = 0; j < references.Length; j++)
             {
                 assemblyArray[j] = new DependentAssembly(new System.Deployment.Application.ReferenceIdentity(references[j].Name.ToString()));
             }
             this._dependentAssemblies = assemblyArray;
             this._manifestSourceFormat = System.Deployment.Application.Manifest.ManifestSourceFormat.CompLib;
             flag = true;
         }
     }
     catch (BadImageFormatException)
     {
         flag = false;
     }
     catch (COMException)
     {
         flag = false;
     }
     catch (SEHException)
     {
         flag = false;
     }
     catch (IOException)
     {
         flag = false;
     }
     return flag;
 }
 private static bool IsResourceReference(DependentAssembly dependentAssembly)
 {
     return (((dependentAssembly.ResourceFallbackCulture != null) && (dependentAssembly.Identity != null)) && (dependentAssembly.Identity.Culture == null));
 }
 public DependentAssembly[] GetPrivateAssembliesInGroup(string group, bool optionalOnly)
 {
     StringComparison invariantCultureIgnoreCase = StringComparison.InvariantCultureIgnoreCase;
     Hashtable hashtable = new Hashtable();
     foreach (DependentAssembly assembly in this.DependentAssemblies)
     {
         if (!assembly.IsPreRequisite && (((group == null) && !assembly.IsOptional) || (((group != null) && group.Equals(assembly.Group, invariantCultureIgnoreCase)) && (assembly.IsOptional || !optionalOnly))))
         {
             DependentAssembly assembly2 = null;
             if (IsResourceReference(assembly))
             {
                 throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_SatelliteResourcesNotSupported"));
             }
             assembly2 = assembly;
             if ((assembly2 != null) && !hashtable.Contains(assembly2.Identity))
             {
                 hashtable.Add(assembly2.Identity, assembly2);
             }
         }
     }
     DependentAssembly[] array = new DependentAssembly[hashtable.Count];
     hashtable.Values.CopyTo(array, 0);
     return array;
 }
 private void PrepareInstallPrivateAssembly(StoreTransactionContext storeTxn, DependentAssembly privAsm, System.Deployment.Application.DefinitionAppId appId, string appPayloadPath)
 {
     string codebaseFS = privAsm.CodebaseFS;
     string path = Path.Combine(appPayloadPath, codebaseFS);
     string directoryName = Path.GetDirectoryName(path);
     AssemblyManifest manifest = new AssemblyManifest(path);
     System.Deployment.Application.DefinitionIdentity asmId = manifest.Identity;
     string rawXmlFilePath = manifest.RawXmlFilePath;
     if (rawXmlFilePath == null)
     {
         rawXmlFilePath = path + ".genman";
         asmId = ManifestGenerator.GenerateManifest(privAsm.Identity, manifest, rawXmlFilePath);
     }
     storeTxn.Add(new System.Deployment.Internal.Isolation.StoreOperationStageComponent(appId.ComPointer, asmId.ComPointer, rawXmlFilePath));
     foreach (System.Deployment.Application.Manifest.File file in manifest.Files)
     {
         this.PrepareInstallFile(storeTxn, file, appId, asmId, directoryName);
     }
 }