Пример #1
0
 private void DeployManager_GetManifestCompleted(object sender, GetManifestCompletedEventArgs e)
 {
     try
     {
         if (e.Error != null)
         {
             ((System.Deployment.Application.InPlaceHostingManager)sender).CancelAsync();
             this.LastError = e.Error;
         }
         else
         {
             this.DeploymentManager.AssertApplicationRequirements(true);
             this.Manifest = new ApplicationManifest(e);
         }
     }
     catch (Exception ex)
     {
         ((System.Deployment.Application.InPlaceHostingManager)sender).CancelAsync();
         this.LastError = (ex.InnerException == null) ? ex : ex.InnerException;
     }
     finally
     {
         this.DeploymentManager.GetManifestCompleted -= DeployManager_GetManifestCompleted;
         //((System.Deployment.Application.InPlaceHostingManager)sender).GetManifestCompleted -= DeployManager_GetManifestCompleted;
         _appManifestSignal.Set();
     }
 }
Пример #2
0
        //</SNIPPET2>

        //<SNIPPET3>
        void iphm_GetManifestCompleted(object sender, GetManifestCompletedEventArgs e)
        {
            // Check for an error.
            if (e.Error != null)
            {
                // Cancel download and install.
                MessageBox.Show("Could not download manifest. Error: " + e.Error.Message);
                return;
            }

            // bool isFullTrust = CheckForFullTrust(e.ApplicationManifest);

            // Verify this application can be installed.
            try
            {
                // the true parameter allows InPlaceHostingManager
                // to grant the permissions requested in the applicaiton manifest.
                iphm.AssertApplicationRequirements(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occurred while verifying the application. " +
                                "Error: " + ex.Message);
                return;
            }

            // Use the information from GetManifestCompleted() to confirm
            // that the user wants to proceed.
            string appInfo = "Application Name: " + e.ProductName;

            appInfo += "\nVersion: " + e.Version;
            appInfo += "\nSupport/Help Requests: " + (e.SupportUri != null ?
                                                      e.SupportUri.ToString() : "N/A");
            appInfo += "\n\nConfirmed that this application can run with its requested permissions.";
            // if (isFullTrust)
            // appInfo += "\n\nThis application requires full trust in order to run.";
            appInfo += "\n\nProceed with installation?";

            DialogResult dr = MessageBox.Show(appInfo, "Confirm Application Install",
                                              MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (dr != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            // Download the deployment manifest.
            iphm.DownloadProgressChanged      += new EventHandler <DownloadProgressChangedEventArgs>(iphm_DownloadProgressChanged);
            iphm.DownloadApplicationCompleted += new EventHandler <DownloadApplicationCompletedEventArgs>(iphm_DownloadApplicationCompleted);

            try
            {
                // Usually this shouldn't throw an exception unless AssertApplicationRequirements() failed,
                // or you did not call that method before calling this one.
                iphm.DownloadApplicationAsync();
            }
            catch (Exception downloadEx)
            {
                MessageBox.Show("Cannot initiate download of application. Error: " +
                                downloadEx.Message);
                return;
            }
        }
Пример #3
0
 private static void OnGetManifestCompleted(object sender, GetManifestCompletedEventArgs args)
 {
     // Console.WriteLine("OnGetManifestCompleted called");
     _event.Set();
 }