コード例 #1
0
        private void SynchronizeGroupCompletedEventHandler(object sender, SynchronizeCompletedEventArgs e)
        {
            Exception         exception         = (Exception)null;
            DeploymentManager deploymentManager = (DeploymentManager)null;

            try
            {
                deploymentManager = (DeploymentManager)sender;
                exception         = e.Error;
            }
            catch (Exception ex)
            {
                if (ExceptionUtility.IsHardException(ex))
                {
                    throw;
                }
                else
                {
                    exception = ex;
                }
            }
            finally
            {
                DownloadFileGroupCompletedEventArgs    e1 = new DownloadFileGroupCompletedEventArgs(e.Error, e.Cancelled, e.UserState, e.Group);
                DownloadFileGroupCompletedEventHandler completedEventHandler = (DownloadFileGroupCompletedEventHandler)this.Events[ApplicationDeployment.downloadFileGroupCompletedKey];
                if (completedEventHandler != null)
                {
                    completedEventHandler((object)this, e1);
                }
            }
        }
コード例 #2
0
        private void EndUpdateAsync(DeploymentManager dm, Exception error, bool cancelled)
        {
            Interlocked.Exchange(ref this._guard, 0);
            AsyncCompletedEventArgs    e = new AsyncCompletedEventArgs(error, cancelled, (object)null);
            AsyncCompletedEventHandler completedEventHandler = (AsyncCompletedEventHandler)this.Events[ApplicationDeployment.updateCompletedKey];

            if (completedEventHandler != null)
            {
                completedEventHandler((object)this, e);
            }
            if (dm == null)
            {
                return;
            }
            dm.ProgressChanged      -= new DeploymentProgressChangedEventHandler(this.UpdateProgressChangedEventHandler);
            dm.BindCompleted        -= new BindCompletedEventHandler(this.UpdateBindCompletedEventHandler);
            dm.SynchronizeCompleted -= new SynchronizeCompletedEventHandler(this.SynchronizeNullCompletedEventHandler);
            new NamedPermissionSet("FullTrust").Assert();
            try
            {
                dm.Dispose();
            }
            finally
            {
                CodeAccessPermission.RevertAssert();
            }
        }
コード例 #3
0
        private void SynchronizeNullCompletedEventHandler(object sender, SynchronizeCompletedEventArgs e)
        {
            Exception         error = (Exception)null;
            DeploymentManager dm    = (DeploymentManager)null;

            new NamedPermissionSet("FullTrust").Assert();
            try
            {
                dm    = (DeploymentManager)sender;
                error = e.Error;
            }
            catch (Exception ex)
            {
                if (ExceptionUtility.IsHardException(ex))
                {
                    throw;
                }
                else
                {
                    error = ex;
                }
            }
            finally
            {
                CodeAccessPermission.RevertAssert();
                this.EndUpdateAsync(dm, error, e.Cancelled);
            }
        }
コード例 #4
0
 /// <summary>Starts a synchronous download and installation of the latest version of this application. </summary>
 /// <returns>true if an application has been updated; otherwise, false.</returns>
 /// <exception cref="T:System.Deployment.Application.TrustNotGrantedException">The local computer did not grant the application the permission level it requested to execute.</exception>
 /// <exception cref="T:System.Deployment.Application.InvalidDeploymentException">Your ClickOnce deployment is corrupted. For tips on how to diagnose and correct the problem, see Troubleshooting ClickOnce Deployments.</exception>
 /// <exception cref="T:System.Deployment.Application.DeploymentDownloadException">The new deployment could not be downloaded from its location on the network.</exception>
 /// <exception cref="T:System.InvalidOperationException">The application is currently being updated.</exception>
 public bool Update()
 {
     new NamedPermissionSet("FullTrust").Demand();
     if (Interlocked.CompareExchange(ref this._guard, 2, 0) != 0)
     {
         throw new InvalidOperationException(Resources.GetString("Ex_SingleOperation"));
     }
     this._cancellationPending = false;
     try
     {
         DeploymentManager deploymentManager = this.CreateDeploymentManager();
         try
         {
             deploymentManager.Bind();
             UpdateCheckInfo updateCheckResult = this.DetermineUpdateCheckResult(deploymentManager.ActivationDescription);
             if (updateCheckResult.UpdateAvailable)
             {
                 deploymentManager.DeterminePlatformRequirements();
                 try
                 {
                     deploymentManager.DetermineTrust(new TrustParams()
                     {
                         NoPrompt = true
                     });
                 }
                 catch (TrustNotGrantedException ex)
                 {
                     if (!deploymentManager.ActivationDescription.IsUpdateInPKTGroup)
                     {
                         throw;
                     }
                 }
             }
             this.ProcessUpdateCheckResult(updateCheckResult, deploymentManager.ActivationDescription);
             if (!updateCheckResult.UpdateAvailable)
             {
                 return(false);
             }
             deploymentManager.Synchronize();
             if (deploymentManager.ActivationDescription.IsUpdateInPKTGroup)
             {
                 this._subState = this._subStore.GetSubscriptionState(deploymentManager.ActivationDescription.DeployManifest);
             }
         }
         finally
         {
             deploymentManager.Dispose();
         }
     }
     finally
     {
         Interlocked.Exchange(ref this._guard, 0);
     }
     return(true);
 }
コード例 #5
0
        /// <summary>Performs the same operation as <see cref="M:System.Deployment.Application.ApplicationDeployment.CheckForUpdate" />, but returns extended information about the available update.</summary>
        /// <returns>An <see cref="T:System.Deployment.Application.UpdateCheckInfo" /> for the available update.</returns>
        /// <param name="persistUpdateCheckResult">If false, the update will be applied silently and no dialog box will be displayed.</param>
        public UpdateCheckInfo CheckForDetailedUpdate(bool persistUpdateCheckResult)
        {
            new NamedPermissionSet("FullTrust").Demand();
            if (Interlocked.CompareExchange(ref this._guard, 2, 0) != 0)
            {
                throw new InvalidOperationException(Resources.GetString("Ex_SingleOperation"));
            }
            this._cancellationPending = false;
            UpdateCheckInfo info = (UpdateCheckInfo)null;

            try
            {
                DeploymentManager deploymentManager = this.CreateDeploymentManager();
                try
                {
                    deploymentManager.Bind();
                    info = this.DetermineUpdateCheckResult(deploymentManager.ActivationDescription);
                    if (info.UpdateAvailable)
                    {
                        deploymentManager.DeterminePlatformRequirements();
                        try
                        {
                            deploymentManager.DetermineTrust(new TrustParams()
                            {
                                NoPrompt = true
                            });
                        }
                        catch (TrustNotGrantedException ex)
                        {
                            if (!deploymentManager.ActivationDescription.IsUpdateInPKTGroup)
                            {
                                throw;
                            }
                        }
                    }
                    if (persistUpdateCheckResult)
                    {
                        this.ProcessUpdateCheckResult(info, deploymentManager.ActivationDescription);
                    }
                }
                finally
                {
                    deploymentManager.Dispose();
                }
            }
            finally
            {
                Interlocked.Exchange(ref this._guard, 0);
            }
            return(info);
        }
コード例 #6
0
        /// <summary>Checks <see cref="P:System.Deployment.Application.ApplicationDeployment.UpdateLocation" /> asynchronously to determine whether a new update is available.</summary>
        /// <exception cref="T:System.InvalidOperationException">ClickOnce throws this exception immediately if you call the <see cref="M:System.Deployment.Application.ApplicationDeployment.CheckForUpdateAsync" />  method while an update is already in progress.</exception>
        /// <exception cref="T:System.Deployment.Application.DeploymentDownloadException">The deployment manifest cannot be downloaded. This exception appears in the <see cref="P:System.ComponentModel.AsyncCompletedEventArgs.Error" /> property of the <see cref="E:System.Deployment.Application.ApplicationDeployment.CheckForUpdateCompleted" /> event.</exception>
        /// <exception cref="T:System.Deployment.Application.InvalidDeploymentException">The deployment manifest is corrupted. You will likely need to redeploy the application to fix this problem. This exception appears in the <see cref="P:System.ComponentModel.AsyncCompletedEventArgs.Error" /> property of the <see cref="E:System.Deployment.Application.ApplicationDeployment.CheckForUpdateCompleted" /> event.</exception>
        public void CheckForUpdateAsync()
        {
            new NamedPermissionSet("FullTrust").Demand();
            if (Interlocked.CompareExchange(ref this._guard, 1, 0) != 0)
            {
                throw new InvalidOperationException(Resources.GetString("Ex_SingleOperation"));
            }
            this._cancellationPending = false;
            DeploymentManager deploymentManager = this.CreateDeploymentManager();

            deploymentManager.ProgressChanged += new DeploymentProgressChangedEventHandler(this.CheckForUpdateProgressChangedEventHandler);
            deploymentManager.BindCompleted   += new BindCompletedEventHandler(this.CheckForUpdateBindCompletedEventHandler);
            deploymentManager.BindAsync();
        }
コード例 #7
0
        private bool BindCoreWithAppId(bool blocking, ref FileStream refTransaction, ref string productName)
        {
            SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(this._bindAppId.DeploymentIdentity.ToSubscriptionId());

            if (!subscriptionState.IsInstalled)
            {
                throw new InvalidDeploymentException(Resources.GetString("Ex_BindAppIdNotInstalled"));
            }
            if (!this._bindAppId.Equals((object)subscriptionState.CurrentBind))
            {
                throw new InvalidDeploymentException(Resources.GetString("Ex_BindAppIdNotCurrrent"));
            }
            if (!blocking && this._cancellationPending)
            {
                return(true);
            }
            long transactionId;

            refTransaction = this._subStore.AcquireReferenceTransaction(out transactionId);
            bool flag = this._subStore.CheckAndReferenceApplication(subscriptionState, this._bindAppId, transactionId);
            ActivationDescription activationDescription = new ActivationDescription();

            activationDescription.SetDeploymentManifest(subscriptionState.CurrentDeploymentManifest, subscriptionState.CurrentDeploymentSourceUri, (string)null);
            Logger.SetDeploymentManifest(this._log, subscriptionState.CurrentDeploymentManifest);
            activationDescription.IsUpdate = this._isupdate;
            activationDescription.SetApplicationManifest(subscriptionState.CurrentApplicationManifest, subscriptionState.CurrentApplicationSourceUri, (string)null);
            Logger.SetApplicationManifest(this._log, subscriptionState.CurrentApplicationManifest);
            Logger.SetApplicationUrl(this._log, subscriptionState.CurrentApplicationSourceUri);
            activationDescription.AppId = new DefinitionAppId(activationDescription.ToAppCodebase(), new DefinitionIdentity[2]
            {
                activationDescription.DeployManifest.Identity,
                activationDescription.AppManifest.Identity
            });
            if (!blocking && this._cancellationPending)
            {
                return(true);
            }
            Description effectiveDescription = subscriptionState.EffectiveDescription;

            productName  = effectiveDescription.Product;
            this._cached = flag;
            Logger.AddInternalState(this._log, "_cached=" + this._cached.ToString());
            Logger.AddInternalState(this._log, "_isupdate=" + this._isupdate.ToString());
            this._referenceTransaction = refTransaction;
            this._actCtx  = DeploymentManager.ConstructActivationContextFromStore(activationDescription.AppId);
            this._actDesc = activationDescription;
            return(false);
        }
 public InPlaceHostingManager(Uri deploymentManifest, bool launchInHostProcess)
 {
     if (!PlatformSpecific.OnXPOrAbove)
     {
         throw new PlatformNotSupportedException(Resources.GetString("Ex_RequiresXPOrHigher"));
     }
     if (deploymentManifest == null)
     {
         throw new ArgumentNullException("deploymentManifest");
     }
     UriHelper.ValidateSupportedSchemeInArgument(deploymentManifest, "deploymentSource");
     this._deploymentManager = new DeploymentManager(deploymentManifest, false, true, null, null);
     this._log = this._deploymentManager.LogId;
     this._isLaunchInHostProcess = launchInHostProcess;
     this._Initialize();
     Logger.AddInternalState(this._log, "Activation through IPHM APIs started.");
     Logger.AddMethodCall(this._log, string.Concat(new object[] { "InPlaceHostingManager(", deploymentManifest, ",", launchInHostProcess.ToString(), ") called." }));
 }
コード例 #9
0
 public InPlaceHostingManager(Uri deploymentManifest, bool launchInHostProcess)
 {
     if (!PlatformSpecific.OnXPOrAbove)
     {
         throw new PlatformNotSupportedException(Resources.GetString("Ex_RequiresXPOrHigher"));
     }
     if (deploymentManifest == null)
     {
         throw new ArgumentNullException("deploymentManifest");
     }
     UriHelper.ValidateSupportedSchemeInArgument(deploymentManifest, "deploymentSource");
     this._deploymentManager = new DeploymentManager(deploymentManifest, false, true, null, null);
     this._log = this._deploymentManager.LogId;
     this._isLaunchInHostProcess = launchInHostProcess;
     this._Initialize();
     Logger.AddInternalState(this._log, "Activation through IPHM APIs started.");
     Logger.AddMethodCall(this._log, string.Concat(new object[] { "InPlaceHostingManager(", deploymentManifest, ",", launchInHostProcess.ToString(), ") called." }));
 }
コード例 #10
0
 private void SynchronizeGroupCompletedEventHandler(object sender, SynchronizeCompletedEventArgs e)
 {
     try
     {
         DeploymentManager manager1 = (DeploymentManager)sender;
         Exception         error    = e.Error;
     }
     catch (Exception exception)
     {
         if (ExceptionUtility.IsHardException(exception))
         {
             throw;
         }
     }
     finally
     {
         DownloadFileGroupCompletedEventArgs    args    = new DownloadFileGroupCompletedEventArgs(e.Error, e.Cancelled, e.UserState, e.Group);
         DownloadFileGroupCompletedEventHandler handler = (DownloadFileGroupCompletedEventHandler)this.Events[downloadFileGroupCompletedKey];
         if (handler != null)
         {
             handler(this, args);
         }
     }
 }
コード例 #11
0
        private void UpdateBindCompletedEventHandler(object sender, BindCompletedEventArgs e)
        {
            Exception         error = (Exception)null;
            DeploymentManager dm    = (DeploymentManager)null;
            bool flag = false;

            new NamedPermissionSet("FullTrust").Assert();
            try
            {
                dm = (DeploymentManager)sender;
                if (e.Error == null && !e.Cancelled)
                {
                    UpdateCheckInfo updateCheckResult = this.DetermineUpdateCheckResult(dm.ActivationDescription);
                    if (updateCheckResult.UpdateAvailable)
                    {
                        dm.DeterminePlatformRequirements();
                        try
                        {
                            dm.DetermineTrust(new TrustParams()
                            {
                                NoPrompt = true
                            });
                        }
                        catch (TrustNotGrantedException ex)
                        {
                            if (!dm.ActivationDescription.IsUpdateInPKTGroup)
                            {
                                throw;
                            }
                        }
                    }
                    this.ProcessUpdateCheckResult(updateCheckResult, dm.ActivationDescription);
                    if (updateCheckResult.UpdateAvailable)
                    {
                        flag = true;
                        dm.SynchronizeAsync();
                    }
                    if (!dm.ActivationDescription.IsUpdateInPKTGroup)
                    {
                        return;
                    }
                    this._subState = this._subStore.GetSubscriptionState(dm.ActivationDescription.DeployManifest);
                }
                else
                {
                    error = e.Error;
                }
            }
            catch (Exception ex)
            {
                if (ExceptionUtility.IsHardException(ex))
                {
                    throw;
                }
                else
                {
                    error = ex;
                }
            }
            finally
            {
                CodeAccessPermission.RevertAssert();
                if (!flag)
                {
                    this.EndUpdateAsync(dm, error, e.Cancelled);
                }
            }
        }
コード例 #12
0
        private void CheckForUpdateBindCompletedEventHandler(object sender, BindCompletedEventArgs e)
        {
            Exception         error             = (Exception)null;
            DeploymentManager deploymentManager = (DeploymentManager)null;
            bool    updateAvailable             = false;
            Version availableVersion            = (Version)null;
            bool    isUpdateRequired            = false;
            Version minimumRequiredVersion      = (Version)null;
            long    updateSize = 0;

            new NamedPermissionSet("FullTrust").Assert();
            try
            {
                deploymentManager = (DeploymentManager)sender;
                if (e.Error == null && !e.Cancelled)
                {
                    UpdateCheckInfo updateCheckResult = this.DetermineUpdateCheckResult(deploymentManager.ActivationDescription);
                    if (updateCheckResult.UpdateAvailable)
                    {
                        deploymentManager.DeterminePlatformRequirements();
                        try
                        {
                            deploymentManager.DetermineTrust(new TrustParams()
                            {
                                NoPrompt = true
                            });
                        }
                        catch (TrustNotGrantedException ex)
                        {
                            if (!deploymentManager.ActivationDescription.IsUpdateInPKTGroup)
                            {
                                throw;
                            }
                        }
                    }
                    this.ProcessUpdateCheckResult(updateCheckResult, deploymentManager.ActivationDescription);
                    if (!updateCheckResult.UpdateAvailable)
                    {
                        return;
                    }
                    updateAvailable        = true;
                    availableVersion       = updateCheckResult.AvailableVersion;
                    isUpdateRequired       = updateCheckResult.IsUpdateRequired;
                    minimumRequiredVersion = updateCheckResult.MinimumRequiredVersion;
                    updateSize             = updateCheckResult.UpdateSizeBytes;
                }
                else
                {
                    error = e.Error;
                }
            }
            catch (Exception ex)
            {
                if (ExceptionUtility.IsHardException(ex))
                {
                    throw;
                }
                else
                {
                    error = ex;
                }
            }
            finally
            {
                CodeAccessPermission.RevertAssert();
                Interlocked.Exchange(ref this._guard, 0);
                CheckForUpdateCompletedEventArgs    e1 = new CheckForUpdateCompletedEventArgs(error, e.Cancelled, (object)null, updateAvailable, availableVersion, isUpdateRequired, minimumRequiredVersion, updateSize);
                CheckForUpdateCompletedEventHandler completedEventHandler = (CheckForUpdateCompletedEventHandler)this.Events[ApplicationDeployment.checkForUpdateCompletedKey];
                if (completedEventHandler != null)
                {
                    completedEventHandler((object)this, e1);
                }
                if (deploymentManager != null)
                {
                    deploymentManager.ProgressChanged -= new DeploymentProgressChangedEventHandler(this.CheckForUpdateProgressChangedEventHandler);
                    deploymentManager.BindCompleted   -= new BindCompletedEventHandler(this.CheckForUpdateBindCompletedEventHandler);
                    new NamedPermissionSet("FullTrust").Assert();
                    try
                    {
                        deploymentManager.Dispose();
                    }
                    finally
                    {
                        CodeAccessPermission.RevertAssert();
                    }
                }
            }
        }
 private void EndUpdateAsync(DeploymentManager dm, Exception error, bool cancelled)
 {
     Interlocked.Exchange(ref this._guard, 0);
     AsyncCompletedEventArgs e = new AsyncCompletedEventArgs(error, cancelled, null);
     AsyncCompletedEventHandler handler = (AsyncCompletedEventHandler) this.Events[updateCompletedKey];
     if (handler != null)
     {
         handler(this, e);
     }
     if (dm != null)
     {
         dm.ProgressChanged -= new DeploymentProgressChangedEventHandler(this.UpdateProgressChangedEventHandler);
         dm.BindCompleted -= new BindCompletedEventHandler(this.UpdateBindCompletedEventHandler);
         dm.SynchronizeCompleted -= new SynchronizeCompletedEventHandler(this.SynchronizeNullCompletedEventHandler);
         new NamedPermissionSet("FullTrust").Assert();
         try
         {
             dm.Dispose();
         }
         finally
         {
             CodeAccessPermission.RevertAssert();
         }
     }
 }
コード例 #14
0
        private void CheckForUpdateBindCompletedEventHandler(object sender, BindCompletedEventArgs e)
        {
            Exception         error        = null;
            DeploymentManager manager      = null;
            bool    updateAvailable        = false;
            Version availableVersion       = null;
            bool    isUpdateRequired       = false;
            Version minimumRequiredVersion = null;
            long    updateSize             = 0L;

            new NamedPermissionSet("FullTrust").Assert();
            try
            {
                manager = (DeploymentManager)sender;
                if ((e.Error == null) && !e.Cancelled)
                {
                    UpdateCheckInfo info = this.DetermineUpdateCheckResult(manager.ActivationDescription);
                    if (info.UpdateAvailable)
                    {
                        manager.DeterminePlatformRequirements();
                        try
                        {
                            TrustParams trustParams = new TrustParams {
                                NoPrompt = true
                            };
                            manager.DetermineTrust(trustParams);
                        }
                        catch (TrustNotGrantedException)
                        {
                            if (!manager.ActivationDescription.IsUpdateInPKTGroup)
                            {
                                throw;
                            }
                        }
                    }
                    this.ProcessUpdateCheckResult(info, manager.ActivationDescription);
                    if (info.UpdateAvailable)
                    {
                        updateAvailable        = true;
                        availableVersion       = info.AvailableVersion;
                        isUpdateRequired       = info.IsUpdateRequired;
                        minimumRequiredVersion = info.MinimumRequiredVersion;
                        updateSize             = info.UpdateSizeBytes;
                    }
                }
                else
                {
                    error = e.Error;
                }
            }
            catch (Exception exception2)
            {
                if (ExceptionUtility.IsHardException(exception2))
                {
                    throw;
                }
                error = exception2;
            }
            finally
            {
                CodeAccessPermission.RevertAssert();
                Interlocked.Exchange(ref this._guard, 0);
                CheckForUpdateCompletedEventArgs    args    = new CheckForUpdateCompletedEventArgs(error, e.Cancelled, null, updateAvailable, availableVersion, isUpdateRequired, minimumRequiredVersion, updateSize);
                CheckForUpdateCompletedEventHandler handler = (CheckForUpdateCompletedEventHandler)this.Events[checkForUpdateCompletedKey];
                if (handler != null)
                {
                    handler(this, args);
                }
                if (manager != null)
                {
                    manager.ProgressChanged -= new DeploymentProgressChangedEventHandler(this.CheckForUpdateProgressChangedEventHandler);
                    manager.BindCompleted   -= new BindCompletedEventHandler(this.CheckForUpdateBindCompletedEventHandler);
                    new NamedPermissionSet("FullTrust").Assert();
                    try
                    {
                        manager.Dispose();
                    }
                    finally
                    {
                        CodeAccessPermission.RevertAssert();
                    }
                }
            }
        }
コード例 #15
0
 private bool SynchronizeCore(bool blocking)
 {
     try
     {
         AssemblyManifest  deployManifest    = this._actDesc.DeployManifest;
         SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(deployManifest);
         this._subStore.CheckDeploymentSubscriptionState(subscriptionState, deployManifest);
         this._subStore.CheckCustomUXFlag(subscriptionState, this._actDesc.AppManifest);
         if (this._actDesc.DeployManifestPath != null)
         {
             this._actDesc.CommitDeploy = true;
             this._actDesc.IsConfirmed  = this._isConfirmed;
             this._actDesc.TimeStamp    = DateTime.UtcNow;
         }
         else
         {
             this._actDesc.CommitDeploy = false;
         }
         if (!blocking && this._cancellationPending)
         {
             return(true);
         }
         if (!this._cached)
         {
             Logger.AddInternalState(this._log, "Application is not cached.");
             bool flag1 = false;
             if (this._actDesc.appType != AppType.CustomHostSpecified)
             {
                 if (this._actDesc.Trust != null)
                 {
                     bool flag2 = this._actDesc.Trust.DefaultGrantSet.PermissionSet.IsUnrestricted();
                     Logger.AddInternalState(this._log, "fullTrust=" + flag2.ToString());
                     if (!flag2 && this._actDesc.AppManifest.FileAssociations.Length != 0)
                     {
                         throw new DeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_FileExtensionNotSupported"));
                     }
                     bool flag3 = !this._actDesc.DeployManifest.Deployment.Install;
                     if (!flag2 & flag3)
                     {
                         Logger.AddInternalState(this._log, "Application is semi-trust and online. Size limits will be checked during download.");
                         if (this._downloadOptions == null)
                         {
                             this._downloadOptions = new DownloadOptions();
                         }
                         this._downloadOptions.EnforceSizeLimit = true;
                         this._downloadOptions.SizeLimit        = this._subStore.GetSizeLimitInBytesForSemiTrustApps();
                         this._downloadOptions.Size             = this._actDesc.DeployManifest.SizeInBytes + this._actDesc.AppManifest.SizeInBytes;
                     }
                 }
                 else
                 {
                     flag1 = true;
                 }
             }
             DownloadManager.DownloadDependencies(subscriptionState, this._actDesc.DeployManifest, this._actDesc.AppManifest, this._actDesc.AppSourceUri, this._tempApplicationDirectory.Path, (string)null, blocking ? (IDownloadNotification)null : (IDownloadNotification)this, this._downloadOptions);
             if (!blocking && this._cancellationPending)
             {
                 return(true);
             }
             this.WaitForAssertApplicationRequirements();
             if (flag1)
             {
                 this.CheckSizeLimit();
             }
             this._actDesc.CommitApp      = true;
             this._actDesc.AppPayloadPath = this._tempApplicationDirectory.Path;
         }
         else
         {
             Logger.AddInternalState(this._log, "Application is cached.");
             this.WaitForAssertApplicationRequirements();
         }
         if (this._actDesc.CommitDeploy || this._actDesc.CommitApp)
         {
             this._subStore.CommitApplication(ref subscriptionState, (CommitApplicationParams)this._actDesc);
             Logger.AddInternalState(this._log, "Application is successfully committed to the store.");
         }
         if (this._tempApplicationDirectory != null)
         {
             this._tempApplicationDirectory.Dispose();
             this._tempApplicationDirectory = (TempDirectory)null;
         }
         if (this._tempDeployment != null)
         {
             this._tempDeployment.Dispose();
             this._tempDeployment = (TempFile)null;
         }
         if (this._referenceTransaction != null)
         {
             this._referenceTransaction.Close();
             this._referenceTransaction = (FileStream)null;
         }
         Logger.AddInternalState(this._log, "Refreshing ActivationContext from store.");
         ActivationContext actCtx = this._actCtx;
         this._actCtx = DeploymentManager.ConstructActivationContextFromStore(this._actDesc.AppId);
         actCtx.Dispose();
         this._cached = true;
     }
     catch (Exception ex)
     {
         this.LogError(Resources.GetString("Ex_DownloadApplicationFailed"), ex);
         Logger.AddInternalState(this._log, "Exception thrown in  SynchronizeCore(): " + ex.GetType().ToString() + " : " + ex.Message + "\r\n" + ex.StackTrace);
         throw;
     }
     return(false);
 }
コード例 #16
0
 private bool BindCore(bool blocking, ref TempFile tempDeploy, ref TempDirectory tempAppDir, ref FileStream refTransaction, ref string productName)
 {
     try
     {
         if (this._deploySource == (Uri)null)
         {
             return(this.BindCoreWithAppId(blocking, ref refTransaction, ref productName));
         }
         Uri deploySource = this._deploySource;
         this._state = DeploymentProgressState.DownloadingDeploymentInformation;
         Logger.AddInternalState(this._log, "Internal state=" + (object)this._state);
         AssemblyManifest      assemblyManifest1 = DownloadManager.DownloadDeploymentManifest(this._subStore, ref deploySource, out tempDeploy, blocking ? (IDownloadNotification)null : (IDownloadNotification)this, this._downloadOptions);
         string                path    = tempDeploy.Path;
         ActivationDescription actDesc = new ActivationDescription();
         actDesc.SetDeploymentManifest(assemblyManifest1, deploySource, path);
         Logger.SetDeploymentManifest(this._log, assemblyManifest1);
         actDesc.IsUpdate = this._isupdate;
         if (actDesc.DeployManifest.Deployment == null)
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_NotDeploymentOrShortcut"));
         }
         if (!blocking && this._cancellationPending)
         {
             return(true);
         }
         long transactionId;
         refTransaction = this._subStore.AcquireReferenceTransaction(out transactionId);
         SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(actDesc.DeployManifest);
         if (actDesc.DeployManifest.Deployment.Install && actDesc.DeployManifest.Deployment.ProviderCodebaseUri == (Uri)null && (subscriptionState != null && subscriptionState.DeploymentProviderUri != (Uri)null) && !subscriptionState.DeploymentProviderUri.Equals((object)deploySource))
         {
             throw new DeploymentException(ExceptionTypes.DeploymentUriDifferent, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_DeploymentUriDifferentExText"), new object[3]
             {
                 (object)actDesc.DeployManifest.Description.FilteredProduct,
                 (object)deploySource.AbsoluteUri,
                 (object)subscriptionState.DeploymentProviderUri.AbsoluteUri
             }));
         }
         DefinitionAppId appId;
         try
         {
             appId = new DefinitionAppId(actDesc.ToAppCodebase(), new DefinitionIdentity[2]
             {
                 actDesc.DeployManifest.Identity,
                 new DefinitionIdentity(actDesc.DeployManifest.MainDependentAssembly.Identity)
             });
         }
         catch (COMException ex)
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_IdentityIsNotValid"), (Exception)ex);
         }
         catch (SEHException ex)
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_IdentityIsNotValid"), (Exception)ex);
         }
         Logger.AddInternalState(this._log, "expectedAppId=" + appId.ToString());
         bool flag1 = this._subStore.CheckAndReferenceApplication(subscriptionState, appId, transactionId);
         if (flag1 && appId.Equals((object)subscriptionState.CurrentBind))
         {
             Logger.AddInternalState(this._log, "Application is found in store and it is the CurrentBind. Binding with appid.");
             this._bindAppId = appId;
             return(this.BindCoreWithAppId(blocking, ref refTransaction, ref productName));
         }
         if (flag1)
         {
             Logger.AddInternalState(this._log, "Application is found in store but it is not the CurrentBind.");
         }
         else
         {
             Logger.AddInternalState(this._log, "Application is not found in store.");
         }
         if (!blocking && this._cancellationPending)
         {
             return(true);
         }
         this._state = DeploymentProgressState.DownloadingApplicationInformation;
         Logger.AddInternalState(this._log, "Internal state=" + (object)this._state);
         tempAppDir = this._subStore.AcquireTempDirectory();
         Uri              appSourceUri;
         string           appManifestPath;
         AssemblyManifest assemblyManifest2 = DownloadManager.DownloadApplicationManifest(actDesc.DeployManifest, tempAppDir.Path, actDesc.DeploySourceUri, blocking ? (IDownloadNotification)null : (IDownloadNotification)this, this._downloadOptions, out appSourceUri, out appManifestPath);
         AssemblyManifest.ReValidateManifestSignatures(actDesc.DeployManifest, assemblyManifest2);
         Logger.SetApplicationManifest(this._log, assemblyManifest2);
         Logger.SetApplicationUrl(this._log, appSourceUri);
         actDesc.SetApplicationManifest(assemblyManifest2, appSourceUri, appManifestPath);
         actDesc.AppId = new DefinitionAppId(actDesc.ToAppCodebase(), new DefinitionIdentity[2]
         {
             actDesc.DeployManifest.Identity,
             actDesc.AppManifest.Identity
         });
         bool flag2 = this._subStore.CheckAndReferenceApplication(subscriptionState, actDesc.AppId, transactionId);
         if (!blocking && this._cancellationPending)
         {
             return(true);
         }
         Description effectiveDescription = actDesc.EffectiveDescription;
         productName  = effectiveDescription.Product;
         this._cached = flag2;
         Logger.AddInternalState(this._log, "_cached=" + this._cached.ToString());
         Logger.AddInternalState(this._log, "_isupdate=" + this._isupdate.ToString());
         this._tempApplicationDirectory = tempAppDir;
         this._tempDeployment           = tempDeploy;
         this._referenceTransaction     = refTransaction;
         this._actCtx  = DeploymentManager.ConstructActivationContext(actDesc);
         this._actDesc = actDesc;
     }
     catch (Exception ex)
     {
         this.LogError(Resources.GetString("Ex_FailedToDownloadManifest"), ex);
         Logger.AddInternalState(this._log, "Exception thrown in  BindCore(): " + ex.GetType().ToString() + " : " + ex.Message + "\r\n" + ex.StackTrace);
         throw;
     }
     return(false);
 }