object AssertApplicationRequirementsAsync(object unused)
        {
            if (IsCanceledOrShuttingDown)
                return null;

            if (CheckAccess()) // initial call by Dispatcher?
            { // Do a callback to a worker thread 
                // Status bar is set on the main thread (here) to avoid switching.
                SetStatusText(SR.Get(SRID.HostingStatusVerifying));

                // Creating an STA thread to get CLR's 'selectively permeable' managed locks. This is needed to
                // enable the dispatching of the window event hook calls needed to intercept the showing of the
                // ClickOnce elevation prompt. See PresentationAppDomainManager.DetermineApplicationTrust().
                Thread thread = new Thread(() => AssertApplicationRequirementsAsync(null));
                thread.SetApartmentState(ApartmentState.STA);
                thread.Name = "IPHM.AAR thread";
                thread.Start();
            }
            else // on a worker thread
            {
                try
                {
                    EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordHosting | EventTrace.Keyword.KeywordPerf, EventTrace.Level.Verbose, EventTrace.Event.WpfHost_AssertAppRequirementsStart);

                    _hostingManager.AssertApplicationRequirements();

                    EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordHosting | EventTrace.Keyword.KeywordPerf, EventTrace.Level.Verbose, EventTrace.Event.WpfHost_AssertAppRequirementsEnd);

                    // Switch to the main thread to update the status message. This is necessary because the
                    // native IBCS and INativeProgressPage interfaces are not marshalable.
                    Dispatcher.BeginInvoke(DispatcherPriority.Normal, new DispatcherOperationCallback(
                        delegate(object unused3)
                        {
                            if (_isInAsynchronousOperation)
                            {
                                ShowDownloadingStatusMessage();
                            }
                            return null;
                        }), null);
                }
                catch (Exception exception0)
                {
                    if (exception0.GetType() == typeof(InvalidOperationException) &&
                        exception0.Source == "System.Deployment")
                    { // "No further operations are possible with this instance":
                        // This condition can occur when IPHM.AssertApplicationRequirements() is called after application
                        // downloading has failed. That error may or may not have been reported to the main thread yet.
                        // Presumably, it is the "real" error that failed deployment and should be reported to the user.
                        // That's why no further handling is done here, and _assertAppRequirementsFailed is not set.
                    }
                    else
                    {
                        _assertAppRequirementsFailed = true;

                        // Note that an exception allowed to escape from here will be caught by the thread-pool manager.
                        // That's why all further processing is moved to the main thread.
                        Dispatcher.BeginInvoke(DispatcherPriority.Send, new DispatcherOperationCallback(
                            delegate(object exceptionObj)
                            {
                                Exception exception = (Exception)exceptionObj;
                                if (CriticalExceptions.IsCriticalException(exception))
                                { // Wrap the exception object in order to preserve the original callstack.
                                    throw new DeploymentException(SR.Get(SRID.UnknownErrorText), exception);
                                }

                                GetManifestCompletedEventArgs args = _getManifestCompletedEventArgs;
                                string version = null;
                                if (exception is TrustNotGrantedException)
                                {
                                    version = GetMissingCustomPermissionVersion(args.ApplicationManifest);
                                    if (!string.IsNullOrEmpty(version))
                                    {
                                        exception = new DependentPlatformMissingException();
                                    }
                                }

                                HandleError(exception, args.LogFilePath, args.SupportUri, version);
                                return null;
                            }), exception0);
                    }
                }
                finally
                {
                    // Synchronize with DoDownloadApplicationCompleted(). [See explanation there.]
                    _assertAppRequirementsEvent.Set();
                }
            }
            return null;
        }
 private void DisplayPlatformDetectionFailureUI(DependentPlatformMissingException ex)
 {
     Uri supportUrl = null;
     if (this._fullTrust)
     {
         supportUrl = ex.SupportUrl;
     }
     this._ui.ShowPlatform(ex.Message, supportUrl);
 }