Export (0) Print
Expand All

ApplicationDeployment.CheckForDetailedUpdate Method

Performs the same operation as CheckForUpdate, but returns extended information about the available update.

Namespace: System.Deployment.Application
Assembly: System.Deployment (in system.deployment.dll)

public:
UpdateCheckInfo^ CheckForDetailedUpdate ()
public UpdateCheckInfo CheckForDetailedUpdate ()
public function CheckForDetailedUpdate () : UpdateCheckInfo
Not applicable.

Return Value

An UpdateCheckInfo for the available update.

Exception typeCondition

InvalidOperationException

The current application is either not configured to support updates, or there is another update check operation already in progress.

DeploymentDownloadException

The deployment manifest cannot be downloaded. This exception will appear in the Error property of the CheckForUpdateCompleted event.

InvalidDeploymentException

The deployment manifest is corrupted. Regenerate the application's manifest before you attempt to deploy this application to users. This exception will appear in the Error property of the CheckForUpdateCompleted event.

The CheckForDetailedUpdate method lets synchronous callers get the same extended information that asynchronous callers get using the CheckForUpdateCompletedEventArgs class.

The following code example uses CheckForDetailedUpdate to retrieve the information about the latest update. If an update exists, it installs it automatically only if it is a required update; otherwise, it prompts the user.

public:
    void InstallUpdateSyncWithInfo()
    {
        if (ApplicationDeployment::IsNetworkDeployed)
        {
            ApplicationDeployment^ deployment =
                ApplicationDeployment::CurrentDeployment;
            UpdateCheckInfo^ updateInfo = nullptr;

            try
            {
                updateInfo = deployment->CheckForDetailedUpdate();
            }
            catch (Exception^ ex)
            {
                MessageBox::Show("The update failed. Error: {0}",
                    ex->Message);
                return;
            }

            if (updateInfo->UpdateAvailable)
            {
                bool doUpdate = true;

                if (!updateInfo->IsUpdateRequired)
                {
                    System::Windows::Forms::DialogResult dr =
                        MessageBox::Show(
                        "An update is available. Would you like to " +
                        "update the application now?",
                        "Update Available",
                        MessageBoxButtons::OKCancel);
                    if (!(System::Windows::Forms::DialogResult::OK == dr))
                    {
                        doUpdate = false;
                    }
                }

                if (doUpdate)
                {
                    try
                    {
                        deployment->Update();
                        MessageBox::Show(
                            "The application has been upgraded, and will " +
                            "now restart.");
                        Application::Restart();
                    }
                    catch (Exception^ ex)
                    {
                        MessageBox::Show("The update failed. Error: {0}",
                            ex->Message);
                        return;
                    }
                }
            }
        }
    }

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft