public void InstallApplication(string deployManifestUriStr) { try { Uri deploymentUri = new Uri(deployManifestUriStr); iphm = new InPlaceHostingManager(deploymentUri, false); } catch (UriFormatException uriEx) { MessageBox.Show("Cannot install the application: " + "The deployment manifest URL supplied is not a valid URL. " + "Error: " + uriEx.Message); return; } catch (PlatformNotSupportedException platformEx) { MessageBox.Show("Cannot install the application: " + "This program requires Windows XP or higher. " + "Error: " + platformEx.Message); return; } catch (ArgumentException argumentEx) { MessageBox.Show("Cannot install the application: " + "The deployment manifest URL supplied is not a valid URL. " + "Error: " + argumentEx.Message); return; } iphm.GetManifestCompleted += new EventHandler<GetManifestCompletedEventArgs>(iphm_GetManifestCompleted); iphm.GetManifestAsync(); }
private static Task GetApplicationManifest(InPlaceHostingManager host) { var completion = new TaskCompletionSource<int>(); host.GetManifestCompleted += (sender, e) => { if (e.Error != null) { completion.SetException(e.Error); } else { completion.SetResult(0); } }; host.GetManifestAsync(); return completion.Task; }
private void InstallApplication(Uri app) { var manager = new InPlaceHostingManager(app, false); manager.GetManifestCompleted += new EventHandler<GetManifestCompletedEventArgs>( OnGetManifestCompleted ); // I would love to just "await manager.GetManifestAsync" here // but GetManifestAsync returns void _event = new AutoResetEvent(false); // Console.WriteLine("Getting manifest for {0}", app); manager.GetManifestAsync(); _event.WaitOne(); // this call is synchronous // Console.WriteLine("Asserting application requirements for {0}", app); manager.AssertApplicationRequirements(true); // Console.WriteLine("AssertApplicationRequirements passes"); manager.DownloadApplicationCompleted += new EventHandler<DownloadApplicationCompletedEventArgs>( OnDownloadApplicationCompleted ); // Console.WriteLine("Downloading and installing {0}", app); manager.DownloadApplicationAsync(); _event.WaitOne(); }