public void ValidateFileAssoctiation(SubscriptionState subState, CommitApplicationParams commitParams)
 {
     if (((commitParams.DeployManifest != null) && (commitParams.AppManifest != null)) && (!commitParams.DeployManifest.Deployment.Install && (commitParams.AppManifest.FileAssociations.Length > 0)))
     {
         throw new DeploymentException(ExceptionTypes.SubscriptionState, Resources.GetString("Ex_OnlineAppWithFileAssociation"));
     }
 }
Пример #2
0
        private void CheckApplicationPayload(CommitApplicationParams commitParams)
        {
            if (commitParams.AppGroup == null && commitParams.appType != AppType.CustomHostSpecified)
            {
                string path = Path.Combine(commitParams.AppPayloadPath, commitParams.AppManifest.EntryPoints[0].CommandFile);
                if (!PlatformDetector.IsWin8orLater())
                {
                    SystemUtils.CheckSupportedImageAndCLRVersions(path);
                }
            }
            string str = (string)null;

            Store.IPathLock pathLock = (Store.IPathLock)null;
            try
            {
                pathLock = this._compStore.LockAssemblyPath(commitParams.AppManifest.Identity);
                str      = Path.GetDirectoryName(pathLock.Path);
                str      = Path.Combine(str, "manifests");
                str      = Path.Combine(str, Path.GetFileName(pathLock.Path) + ".manifest");
            }
            catch (DeploymentException ex)
            {
            }
            catch (COMException ex)
            {
            }
            finally
            {
                if (pathLock != null)
                {
                    pathLock.Dispose();
                }
            }
            if (string.IsNullOrEmpty(str) || !System.IO.File.Exists(str) || (string.IsNullOrEmpty(commitParams.AppManifestPath) || !System.IO.File.Exists(commitParams.AppManifestPath)))
            {
                return;
            }
            byte[] digestValue1 = ComponentVerifier.GenerateDigestValue(str, CMS_HASH_DIGESTMETHOD.CMS_HASH_DIGESTMETHOD_SHA1, CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY);
            byte[] digestValue2 = ComponentVerifier.GenerateDigestValue(commitParams.AppManifestPath, CMS_HASH_DIGESTMETHOD.CMS_HASH_DIGESTMETHOD_SHA1, CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY);
            bool   flag         = false;

            Logger.AddInternalState("In-place update check. Existing manifest path = " + str + ", Existing manifest hash=" + Encoding.UTF8.GetString(digestValue1) + ", New manifest path=" + commitParams.AppManifestPath + ", New manifest hash=" + Encoding.UTF8.GetString(digestValue2));
            if (digestValue1.Length == digestValue2.Length)
            {
                int index = 0;
                while (index < digestValue1.Length && (int)digestValue1[index] == (int)digestValue2[index])
                {
                    ++index;
                }
                if (index >= digestValue1.Length)
                {
                    flag = true;
                }
            }
            if (!flag)
            {
                throw new DeploymentException(ExceptionTypes.Subscription, Resources.GetString("Ex_ApplicationInplaceUpdate"));
            }
        }
        private void CheckApplicationPayload(CommitApplicationParams commitParams)
        {
            if ((commitParams.AppGroup == null) && (commitParams.appType != AppType.CustomHostSpecified))
            {
                SystemUtils.CheckSupportedImageAndCLRVersions(Path.Combine(commitParams.AppPayloadPath, commitParams.AppManifest.EntryPoints[0].CommandFile));
            }
            string directoryName = null;

            System.Deployment.Internal.Isolation.Store.IPathLock @lock = null;
            try
            {
                @lock         = this._compStore.LockAssemblyPath(commitParams.AppManifest.Identity);
                directoryName = Path.GetDirectoryName(@lock.Path);
                directoryName = Path.Combine(directoryName, "manifests");
                directoryName = Path.Combine(directoryName, Path.GetFileName(@lock.Path) + ".manifest");
            }
            catch (DeploymentException)
            {
            }
            catch (COMException)
            {
            }
            finally
            {
                if (@lock != null)
                {
                    @lock.Dispose();
                }
            }
            if ((!string.IsNullOrEmpty(directoryName) && System.IO.File.Exists(directoryName)) && (!string.IsNullOrEmpty(commitParams.AppManifestPath) && System.IO.File.Exists(commitParams.AppManifestPath)))
            {
                byte[] bytes   = ComponentVerifier.GenerateDigestValue(directoryName, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD.CMS_HASH_DIGESTMETHOD_SHA1, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY);
                byte[] buffer2 = ComponentVerifier.GenerateDigestValue(commitParams.AppManifestPath, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD.CMS_HASH_DIGESTMETHOD_SHA1, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY);
                bool   flag    = false;
                Logger.AddInternalState("In-place update check. Existing manifest path = " + directoryName + ", Existing manifest hash=" + Encoding.UTF8.GetString(bytes) + ", New manifest path=" + commitParams.AppManifestPath + ", New manifest hash=" + Encoding.UTF8.GetString(buffer2));
                if (bytes.Length == buffer2.Length)
                {
                    int index = 0;
                    while (index < bytes.Length)
                    {
                        if (bytes[index] != buffer2[index])
                        {
                            break;
                        }
                        index++;
                    }
                    if (index >= bytes.Length)
                    {
                        flag = true;
                    }
                }
                if (!flag)
                {
                    throw new DeploymentException(ExceptionTypes.Subscription, Resources.GetString("Ex_ApplicationInplaceUpdate"));
                }
            }
        }
Пример #4
0
        private bool SynchronizeGroupCore(bool blocking, SyncGroupHelper sgh)
        {
            TempDirectory directory = null;

            try
            {
                string            group             = sgh.Group;
                SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(this._actDesc.DeployManifest);
                if (this._subStore.CheckGroupInstalled(subscriptionState, this._actDesc.AppId, this._actDesc.AppManifest, group))
                {
                    return(false);
                }
                bool flag = AppDomain.CurrentDomain.ApplicationTrust.DefaultGrantSet.PermissionSet.IsUnrestricted();
                if (!flag && (this._actDesc.AppManifest.FileAssociations.Length > 0))
                {
                    throw new DeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_FileExtensionNotSupported"));
                }
                bool flag2 = !this._actDesc.DeployManifest.Deployment.Install;
                if (!flag && flag2)
                {
                    if (this._downloadOptions == null)
                    {
                        this._downloadOptions = new DownloadOptions();
                    }
                    this._downloadOptions.EnforceSizeLimit = true;
                    this._downloadOptions.SizeLimit        = this._subStore.GetSizeLimitInBytesForSemiTrustApps();
                    this._downloadOptions.Size             = this._subStore.GetPrivateSize(this._actDesc.AppId);
                }
                directory = this._subStore.AcquireTempDirectory();
                DownloadManager.DownloadDependencies(subscriptionState, this._actDesc.DeployManifest, this._actDesc.AppManifest, this._actDesc.AppSourceUri, directory.Path, group, blocking ? null : sgh, this._downloadOptions);
                if (!blocking && sgh.CancellationPending)
                {
                    return(true);
                }
                CommitApplicationParams commitParams = new CommitApplicationParams(this._actDesc)
                {
                    CommitApp       = true,
                    AppPayloadPath  = directory.Path,
                    AppManifestPath = null,
                    AppGroup        = group,
                    CommitDeploy    = false
                };
                this._subStore.CommitApplication(ref subscriptionState, commitParams);
            }
            finally
            {
                this.DetachFromGroup(sgh);
                if (directory != null)
                {
                    directory.Dispose();
                }
            }
            return(false);
        }
Пример #5
0
 public CommitApplicationParams(CommitApplicationParams src)
 {
     this.AppId                = src.AppId;
     this.CommitApp            = src.CommitApp;
     this.AppManifest          = src.AppManifest;
     this.AppSourceUri         = src.AppSourceUri;
     this.AppManifestPath      = src.AppManifestPath;
     this.AppPayloadPath       = src.AppPayloadPath;
     this.AppGroup             = src.AppGroup;
     this.CommitDeploy         = src.CommitDeploy;
     this.DeployManifest       = src.DeployManifest;
     this.DeploySourceUri      = src.DeploySourceUri;
     this.DeployManifestPath   = src.DeployManifestPath;
     this.TimeStamp            = src.TimeStamp;
     this.IsConfirmed          = src.IsConfirmed;
     this.IsUpdate             = src.IsUpdate;
     this.IsRequiredUpdate     = src.IsRequiredUpdate;
     this.IsUpdateInPKTGroup   = src.IsUpdateInPKTGroup;
     this.IsFullTrustRequested = src.IsFullTrustRequested;
     this.appType              = src.appType;
     this.Trust                = src.Trust;
 }
 public CommitApplicationParams(CommitApplicationParams src)
 {
     this.TimeStamp = DateTime.MinValue;
     this.AppId = src.AppId;
     this.CommitApp = src.CommitApp;
     this.AppManifest = src.AppManifest;
     this.AppSourceUri = src.AppSourceUri;
     this.AppManifestPath = src.AppManifestPath;
     this.AppPayloadPath = src.AppPayloadPath;
     this.AppGroup = src.AppGroup;
     this.CommitDeploy = src.CommitDeploy;
     this.DeployManifest = src.DeployManifest;
     this.DeploySourceUri = src.DeploySourceUri;
     this.DeployManifestPath = src.DeployManifestPath;
     this.TimeStamp = src.TimeStamp;
     this.IsConfirmed = src.IsConfirmed;
     this.IsUpdate = src.IsUpdate;
     this.IsRequiredUpdate = src.IsRequiredUpdate;
     this.IsUpdateInPKTGroup = src.IsUpdateInPKTGroup;
     this.IsFullTrustRequested = src.IsFullTrustRequested;
     this.appType = src.appType;
     this.Trust = src.Trust;
 }
 private bool SynchronizeGroupCore(bool blocking, SyncGroupHelper sgh)
 {
     TempDirectory directory = null;
     try
     {
         string group = sgh.Group;
         SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(this._actDesc.DeployManifest);
         if (this._subStore.CheckGroupInstalled(subscriptionState, this._actDesc.AppId, this._actDesc.AppManifest, group))
         {
             return false;
         }
         bool flag = AppDomain.CurrentDomain.ApplicationTrust.DefaultGrantSet.PermissionSet.IsUnrestricted();
         if (!flag && (this._actDesc.AppManifest.FileAssociations.Length > 0))
         {
             throw new DeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_FileExtensionNotSupported"));
         }
         bool flag2 = !this._actDesc.DeployManifest.Deployment.Install;
         if (!flag && flag2)
         {
             if (this._downloadOptions == null)
             {
                 this._downloadOptions = new DownloadOptions();
             }
             this._downloadOptions.EnforceSizeLimit = true;
             this._downloadOptions.SizeLimit = this._subStore.GetSizeLimitInBytesForSemiTrustApps();
             this._downloadOptions.Size = this._subStore.GetPrivateSize(this._actDesc.AppId);
         }
         directory = this._subStore.AcquireTempDirectory();
         DownloadManager.DownloadDependencies(subscriptionState, this._actDesc.DeployManifest, this._actDesc.AppManifest, this._actDesc.AppSourceUri, directory.Path, group, blocking ? null : sgh, this._downloadOptions);
         if (!blocking && sgh.CancellationPending)
         {
             return true;
         }
         CommitApplicationParams commitParams = new CommitApplicationParams(this._actDesc) {
             CommitApp = true,
             AppPayloadPath = directory.Path,
             AppManifestPath = null,
             AppGroup = group,
             CommitDeploy = false
         };
         this._subStore.CommitApplication(ref subscriptionState, commitParams);
     }
     finally
     {
         this.DetachFromGroup(sgh);
         if (directory != null)
         {
             directory.Dispose();
         }
     }
     return false;
 }
 public void ValidateFileAssoctiation(SubscriptionState subState, CommitApplicationParams commitParams)
 {
     if (((commitParams.DeployManifest != null) && (commitParams.AppManifest != null)) && (!commitParams.DeployManifest.Deployment.Install && (commitParams.AppManifest.FileAssociations.Length > 0)))
     {
         throw new DeploymentException(ExceptionTypes.SubscriptionState, Resources.GetString("Ex_OnlineAppWithFileAssociation"));
     }
 }
 private void PrepareCommitApplication(StoreTransactionContext storeTxn, SubscriptionState subState, CommitApplicationParams commitParams)
 {
     System.Deployment.Application.DefinitionAppId appId = commitParams.AppId;
     SubscriptionStateInternal newState = null;
     if (commitParams.CommitDeploy)
     {
         newState = this.PrepareCommitDeploymentState(storeTxn, subState, commitParams);
         if ((commitParams.IsConfirmed && appId.Equals(newState.CurrentBind)) || (!commitParams.IsConfirmed && appId.Equals(newState.PendingBind)))
         {
             this.PrepareStageDeploymentComponent(storeTxn, subState, commitParams);
         }
     }
     if (commitParams.CommitApp)
     {
         this.PrepareStageAppComponent(storeTxn, commitParams);
         if (!commitParams.DeployManifest.Deployment.Install && (commitParams.appType != AppType.CustomHostSpecified))
         {
             storeTxn.ScavengeContext.AddOnlineAppToCommit(appId, subState);
         }
     }
     if (commitParams.CommitDeploy)
     {
         this.PrepareSetSubscriptionState(storeTxn, subState, newState);
     }
 }
 private void CheckApplicationPayload(CommitApplicationParams commitParams)
 {
     if ((commitParams.AppGroup == null) && (commitParams.appType != AppType.CustomHostSpecified))
     {
         SystemUtils.CheckSupportedImageAndCLRVersions(Path.Combine(commitParams.AppPayloadPath, commitParams.AppManifest.EntryPoints[0].CommandFile));
     }
     string directoryName = null;
     System.Deployment.Internal.Isolation.Store.IPathLock @lock = null;
     try
     {
         @lock = this._compStore.LockAssemblyPath(commitParams.AppManifest.Identity);
         directoryName = Path.GetDirectoryName(@lock.Path);
         directoryName = Path.Combine(directoryName, "manifests");
         directoryName = Path.Combine(directoryName, Path.GetFileName(@lock.Path) + ".manifest");
     }
     catch (DeploymentException)
     {
     }
     catch (COMException)
     {
     }
     finally
     {
         if (@lock != null)
         {
             @lock.Dispose();
         }
     }
     if ((!string.IsNullOrEmpty(directoryName) && System.IO.File.Exists(directoryName)) && (!string.IsNullOrEmpty(commitParams.AppManifestPath) && System.IO.File.Exists(commitParams.AppManifestPath)))
     {
         byte[] bytes = ComponentVerifier.GenerateDigestValue(directoryName, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD.CMS_HASH_DIGESTMETHOD_SHA1, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY);
         byte[] buffer2 = ComponentVerifier.GenerateDigestValue(commitParams.AppManifestPath, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD.CMS_HASH_DIGESTMETHOD_SHA1, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY);
         bool flag = false;
         Logger.AddInternalState("In-place update check. Existing manifest path = " + directoryName + ", Existing manifest hash=" + Encoding.UTF8.GetString(bytes) + ", New manifest path=" + commitParams.AppManifestPath + ", New manifest hash=" + Encoding.UTF8.GetString(buffer2));
         if (bytes.Length == buffer2.Length)
         {
             int index = 0;
             while (index < bytes.Length)
             {
                 if (bytes[index] != buffer2[index])
                 {
                     break;
                 }
                 index++;
             }
             if (index >= bytes.Length)
             {
                 flag = true;
             }
         }
         if (!flag)
         {
             throw new DeploymentException(ExceptionTypes.Subscription, Resources.GetString("Ex_ApplicationInplaceUpdate"));
         }
     }
 }
 private void PrepareStageDeploymentComponent(StoreTransactionContext storeTxn, SubscriptionState subState, CommitApplicationParams commitParams)
 {
     System.Deployment.Application.DefinitionAppId id = commitParams.AppId.ToDeploymentAppId();
     string deployManifestPath = commitParams.DeployManifestPath;
     storeTxn.Add(new System.Deployment.Internal.Isolation.StoreOperationStageComponent(id.ComPointer, deployManifestPath));
     this.PrepareSetDeploymentProperties(storeTxn, commitParams.AppId, commitParams);
 }
 private void PrepareStageAppComponent(StoreTransactionContext storeTxn, CommitApplicationParams commitParams)
 {
     System.Deployment.Application.DefinitionAppId appId = commitParams.AppId;
     AssemblyManifest appManifest = commitParams.AppManifest;
     string appManifestPath = commitParams.AppManifestPath;
     string appPayloadPath = commitParams.AppPayloadPath;
     string appGroup = commitParams.AppGroup;
     if (appGroup == null)
     {
         if (appManifestPath == null)
         {
             throw new ArgumentNullException("commitParams");
         }
         storeTxn.Add(new System.Deployment.Internal.Isolation.StoreOperationStageComponent(appId.ComPointer, appManifestPath));
     }
     foreach (System.Deployment.Application.Manifest.File file in appManifest.GetFilesInGroup(appGroup, true))
     {
         this.PrepareInstallFile(storeTxn, file, appId, null, appPayloadPath);
     }
     foreach (DependentAssembly assembly in appManifest.GetPrivateAssembliesInGroup(appGroup, true))
     {
         this.PrepareInstallPrivateAssembly(storeTxn, assembly, appId, appPayloadPath);
     }
 }
 private void PrepareSetDeploymentProperties(StoreTransactionContext storeTxn, System.Deployment.Application.DefinitionAppId appId, CommitApplicationParams commitParams)
 {
     string str = null;
     string str2 = null;
     string str3 = null;
     if (commitParams != null)
     {
         str = ToPropertyString(commitParams.DeploySourceUri);
         str2 = ToPropertyString(commitParams.AppSourceUri);
         if ((commitParams.IsUpdateInPKTGroup && (commitParams.Trust == null)) && commitParams.IsFullTrustRequested)
         {
             str3 = ToPropertyString(commitParams.IsFullTrustRequested);
         }
         else if (commitParams.IsUpdate && (commitParams.Trust == null))
         {
             str3 = null;
         }
         else if (commitParams.appType == AppType.CustomHostSpecified)
         {
             str3 = null;
         }
         else
         {
             str3 = ToPropertyString(commitParams.Trust.DefaultGrantSet.PermissionSet.IsUnrestricted());
         }
     }
     System.Deployment.Internal.Isolation.StoreOperationMetadataProperty[] setProperties = new System.Deployment.Internal.Isolation.StoreOperationMetadataProperty[] { new System.Deployment.Internal.Isolation.StoreOperationMetadataProperty(Constants.DeploymentPropertySet, "DeploymentSourceUri", str), new System.Deployment.Internal.Isolation.StoreOperationMetadataProperty(Constants.DeploymentPropertySet, "ApplicationSourceUri", str2), new System.Deployment.Internal.Isolation.StoreOperationMetadataProperty(Constants.DeploymentPropertySet, "IsFullTrust", str3) };
     storeTxn.Add(new System.Deployment.Internal.Isolation.StoreOperationSetDeploymentMetadata(appId.ComPointer, this.InstallReference, setProperties));
 }
 private SubscriptionStateInternal PrepareCommitDeploymentState(StoreTransactionContext storeTxn, SubscriptionState subState, CommitApplicationParams commitParams)
 {
     System.Deployment.Application.DefinitionAppId appId = commitParams.AppId;
     AssemblyManifest deployManifest = commitParams.DeployManifest;
     SubscriptionStateInternal newState = new SubscriptionStateInternal(subState);
     if (commitParams.IsConfirmed)
     {
         newState.IsInstalled = true;
         newState.IsShellVisible = deployManifest.Deployment.Install;
         newState.DeploymentProviderUri = (deployManifest.Deployment.ProviderCodebaseUri != null) ? deployManifest.Deployment.ProviderCodebaseUri : commitParams.DeploySourceUri;
         if (deployManifest.Deployment.MinimumRequiredVersion != null)
         {
             newState.MinimumRequiredVersion = deployManifest.Deployment.MinimumRequiredVersion;
         }
         if (!appId.Equals(subState.CurrentBind))
         {
             newState.CurrentBind = appId;
             newState.PreviousBind = (newState.IsShellVisible && !subState.IsShellVisible) ? null : subState.CurrentBind;
         }
         newState.PendingBind = null;
         newState.PendingDeployment = null;
         newState.ExcludedDeployment = null;
         newState.appType = commitParams.appType;
         ResetUpdateSkippedState(newState);
     }
     else
     {
         newState.PendingBind = appId;
         newState.PendingDeployment = appId.DeploymentIdentity;
         if (!newState.PendingDeployment.Equals(subState.UpdateSkippedDeployment))
         {
             ResetUpdateSkippedState(newState);
         }
     }
     newState.LastCheckTime = commitParams.TimeStamp;
     FinalizeSubscriptionState(newState);
     return newState;
 }
 public void CommitApplication(ref SubscriptionState subState, CommitApplicationParams commitParams)
 {
     Logger.AddMethodCall("CommitApplication called.");
     using (this.AcquireSubscriptionWriterLock(subState))
     {
         if (commitParams.CommitDeploy)
         {
             Logger.AddInternalState("Commiting Deployment :  subscription metadata.");
             UriHelper.ValidateSupportedScheme(commitParams.DeploySourceUri);
             this.CheckDeploymentSubscriptionState(subState, commitParams.DeployManifest);
             this.ValidateFileAssoctiation(subState, commitParams);
             if (commitParams.IsUpdate && !commitParams.IsUpdateInPKTGroup)
             {
                 CheckInstalled(subState);
             }
         }
         if (commitParams.CommitApp)
         {
             Logger.AddInternalState("Commiting Application:  application binaries.");
             UriHelper.ValidateSupportedScheme(commitParams.AppSourceUri);
             if (commitParams.AppGroup != null)
             {
                 CheckInstalled(subState);
             }
             this.CheckApplicationPayload(commitParams);
         }
         bool      flag = false;
         bool      identityGroupFound       = false;
         bool      locationGroupFound       = false;
         string    identityGroupProductName = "";
         ArrayList list = this._compStore.CollectCrossGroupApplications(commitParams.DeploySourceUri, commitParams.DeployManifest.Identity, ref identityGroupFound, ref locationGroupFound, ref identityGroupProductName);
         if (list.Count > 0)
         {
             flag = true;
             Logger.AddInternalState("This installation is a Cross Group: identityGroupFound=" + identityGroupFound.ToString() + ",locationGroupFound=" + locationGroupFound.ToString());
         }
         if ((subState.IsShellVisible && identityGroupFound) && locationGroupFound)
         {
             throw new DeploymentException(ExceptionTypes.GroupMultipleMatch, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_GroupMultipleMatch"), new object[] { identityGroupProductName }));
         }
         subState = this.GetSubscriptionState(commitParams.DeployManifest);
         this._compStore.CommitApplication(subState, commitParams);
         if (flag)
         {
             uint num;
             Logger.AddInternalState("Performing cross group migration.");
             System.Deployment.Internal.Isolation.IActContext context = System.Deployment.Internal.Isolation.IsolationInterop.CreateActContext(subState.CurrentBind.ComPointer);
             context.PrepareForExecution(IntPtr.Zero, IntPtr.Zero);
             context.SetApplicationRunningState(0, 1, out num);
             context.SetApplicationRunningState(0, 2, out num);
             Logger.AddInternalState("Uninstalling all cross groups.");
             foreach (ComponentStore.CrossGroupApplicationData data in list)
             {
                 if (data.CrossGroupType == ComponentStore.CrossGroupApplicationData.GroupType.LocationGroup)
                 {
                     if (data.SubState.appType == AppType.CustomHostSpecified)
                     {
                         Logger.AddInternalState("UninstallCustomHostSpecifiedSubscription : " + ((data.SubState.SubscriptionId != null) ? data.SubState.SubscriptionId.ToString() : "null"));
                         this.UninstallCustomHostSpecifiedSubscription(data.SubState);
                     }
                     else if (data.SubState.appType == AppType.CustomUX)
                     {
                         Logger.AddInternalState("UninstallCustomUXSubscription : " + ((data.SubState.SubscriptionId != null) ? data.SubState.SubscriptionId.ToString() : "null"));
                         this.UninstallCustomUXSubscription(data.SubState);
                     }
                     else if (data.SubState.IsShellVisible)
                     {
                         Logger.AddInternalState("UninstallSubscription : " + ((data.SubState.SubscriptionId != null) ? data.SubState.SubscriptionId.ToString() : "null"));
                         this.UninstallSubscription(data.SubState);
                     }
                 }
                 else if (data.CrossGroupType == ComponentStore.CrossGroupApplicationData.GroupType.IdentityGroup)
                 {
                     Logger.AddInternalState("Not uninstalled :" + ((data.SubState.SubscriptionId != null) ? data.SubState.SubscriptionId.ToString() : "null") + ". It is in the identity group.");
                 }
             }
         }
         if ((commitParams.IsConfirmed && subState.IsInstalled) && (subState.IsShellVisible && (commitParams.appType != AppType.CustomUX)))
         {
             this.UpdateSubscriptionExposure(subState);
         }
         if (commitParams.appType == AppType.CustomUX)
         {
             ShellExposure.ShellExposureInformation shellExposureInformation = ShellExposure.ShellExposureInformation.CreateShellExposureInformation(subState.SubscriptionId);
             ShellExposure.UpdateShellExtensions(subState, ref shellExposureInformation);
         }
         OnDeploymentAdded(subState);
     }
 }
 public void CommitApplication(ref SubscriptionState subState, CommitApplicationParams commitParams)
 {
     Logger.AddMethodCall("CommitApplication called.");
     using (this.AcquireSubscriptionWriterLock(subState))
     {
         if (commitParams.CommitDeploy)
         {
             Logger.AddInternalState("Commiting Deployment :  subscription metadata.");
             UriHelper.ValidateSupportedScheme(commitParams.DeploySourceUri);
             this.CheckDeploymentSubscriptionState(subState, commitParams.DeployManifest);
             this.ValidateFileAssoctiation(subState, commitParams);
             if (commitParams.IsUpdate && !commitParams.IsUpdateInPKTGroup)
             {
                 CheckInstalled(subState);
             }
         }
         if (commitParams.CommitApp)
         {
             Logger.AddInternalState("Commiting Application:  application binaries.");
             UriHelper.ValidateSupportedScheme(commitParams.AppSourceUri);
             if (commitParams.AppGroup != null)
             {
                 CheckInstalled(subState);
             }
             this.CheckApplicationPayload(commitParams);
         }
         bool flag = false;
         bool identityGroupFound = false;
         bool locationGroupFound = false;
         string identityGroupProductName = "";
         ArrayList list = this._compStore.CollectCrossGroupApplications(commitParams.DeploySourceUri, commitParams.DeployManifest.Identity, ref identityGroupFound, ref locationGroupFound, ref identityGroupProductName);
         if (list.Count > 0)
         {
             flag = true;
             Logger.AddInternalState("This installation is a Cross Group: identityGroupFound=" + identityGroupFound.ToString() + ",locationGroupFound=" + locationGroupFound.ToString());
         }
         if ((subState.IsShellVisible && identityGroupFound) && locationGroupFound)
         {
             throw new DeploymentException(ExceptionTypes.GroupMultipleMatch, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_GroupMultipleMatch"), new object[] { identityGroupProductName }));
         }
         subState = this.GetSubscriptionState(commitParams.DeployManifest);
         this._compStore.CommitApplication(subState, commitParams);
         if (flag)
         {
             uint num;
             Logger.AddInternalState("Performing cross group migration.");
             System.Deployment.Internal.Isolation.IActContext context = System.Deployment.Internal.Isolation.IsolationInterop.CreateActContext(subState.CurrentBind.ComPointer);
             context.PrepareForExecution(IntPtr.Zero, IntPtr.Zero);
             context.SetApplicationRunningState(0, 1, out num);
             context.SetApplicationRunningState(0, 2, out num);
             Logger.AddInternalState("Uninstalling all cross groups.");
             foreach (ComponentStore.CrossGroupApplicationData data in list)
             {
                 if (data.CrossGroupType == ComponentStore.CrossGroupApplicationData.GroupType.LocationGroup)
                 {
                     if (data.SubState.appType == AppType.CustomHostSpecified)
                     {
                         Logger.AddInternalState("UninstallCustomHostSpecifiedSubscription : " + ((data.SubState.SubscriptionId != null) ? data.SubState.SubscriptionId.ToString() : "null"));
                         this.UninstallCustomHostSpecifiedSubscription(data.SubState);
                     }
                     else if (data.SubState.appType == AppType.CustomUX)
                     {
                         Logger.AddInternalState("UninstallCustomUXSubscription : " + ((data.SubState.SubscriptionId != null) ? data.SubState.SubscriptionId.ToString() : "null"));
                         this.UninstallCustomUXSubscription(data.SubState);
                     }
                     else if (data.SubState.IsShellVisible)
                     {
                         Logger.AddInternalState("UninstallSubscription : " + ((data.SubState.SubscriptionId != null) ? data.SubState.SubscriptionId.ToString() : "null"));
                         this.UninstallSubscription(data.SubState);
                     }
                 }
                 else if (data.CrossGroupType == ComponentStore.CrossGroupApplicationData.GroupType.IdentityGroup)
                 {
                     Logger.AddInternalState("Not uninstalled :" + ((data.SubState.SubscriptionId != null) ? data.SubState.SubscriptionId.ToString() : "null") + ". It is in the identity group.");
                 }
             }
         }
         if ((commitParams.IsConfirmed && subState.IsInstalled) && (subState.IsShellVisible && (commitParams.appType != AppType.CustomUX)))
         {
             this.UpdateSubscriptionExposure(subState);
         }
         if (commitParams.appType == AppType.CustomUX)
         {
             ShellExposure.ShellExposureInformation shellExposureInformation = ShellExposure.ShellExposureInformation.CreateShellExposureInformation(subState.SubscriptionId);
             ShellExposure.UpdateShellExtensions(subState, ref shellExposureInformation);
         }
         OnDeploymentAdded(subState);
     }
 }
 public void CommitApplication(SubscriptionState subState, CommitApplicationParams commitParams)
 {
     try
     {
         using (StoreTransactionContext context = new StoreTransactionContext(this))
         {
             this.PrepareCommitApplication(context, subState, commitParams);
             this.SubmitStoreTransactionCheckQuota(context, subState);
         }
     }
     catch (COMException exception)
     {
         if (exception.ErrorCode == -2147024784)
         {
             throw new DeploymentException(ExceptionTypes.DiskIsFull, Resources.GetString("Ex_StoreOperationFailed"), exception);
         }
         if (exception.ErrorCode == -2147023590)
         {
             throw new DeploymentException(ExceptionTypes.ComponentStore, Resources.GetString("Ex_InplaceUpdateOfApplicationAttempted"), exception);
         }
         throw;
     }
 }