ClickOnce applications can check for updates automatically or programmatically. As a developer, you have lots of flexibility in specifying when and how update checks are performed, whether updates are mandatory, and where the application should check for updates.

You can configure the application to check for updates automatically before the application starts, or at set intervals after the application starts. In addition you can specify a minimum required version; that is, an update is installed if the user's version is lower than the required version.

You can configure the application to check for updates programmatically based on an event such as a user request. The procedure "To check for updates programmatically" in this topic shows how you would write code that uses the ApplicationDeployment class to check for updates based on an event.

You can also deploy your application from one location and update it from another. See the procedure "To specify a different update location."

Update behavior is managed in the Application Updates dialog box, available from the Publish page of the Project Designer.

To check for updates before the application starts

With a project selected in Solution Explorer, on the Project menu, click Properties.

Click the Publish tab.

Click the Updates button to open the Application Updates dialog box.

In the Application Updates dialog box, make sure that the The application should check for updates check box is selected.

In the Choose when the application should check for updates section, select Before the application starts. This ensures that users connected to the network always run the application with the latest updates.

To check for updates in the background after the application starts

With a project selected in Solution Explorer, on the Project menu, click Properties.

Click the Publish tab.

Click the Updates button to open the Application Updates dialog box.

In the Application Updates dialog box, make sure that the check box The application should check for updates is selected.

In the Choose when the application should check for updates section, select After the application starts. The application will start more quickly this way, and then it will check for updates in the background, and only notify the user when an update is available. Once installed, updates will not take effect until the application is restarted.

In the Specify how frequently the application should check for updates section, select either Check every time the application runs (the default) or Check every and enter a number and time interval.

To specify a minimum required version for the application

With a project selected in Solution Explorer, on the Project menu, click Properties.

Click the Publish tab.

Click the Updates button to open the Application Updates dialog box.

In the Application Updates dialog box, make sure that the The application should check for updates check box is selected.

Select the Specify a minimum required version for this application check box, and then enter Major, Minor, Build, and Revision numbers for the application.

To specify a different update location

With a project selected in Solution Explorer, on the Project menu, click Properties.

Click the Publish tab.

Click the Updates button to open the Application Updates dialog box.

In the Application Updates dialog box, make sure that the The application should check for updates check box is selected.

In the Update location field, enter the update location with a fully qualified URL, using the format http://Hostname/ApplicationName, or a UNC path using the format \\Server\ApplicationName, or click the Browse button to browse for the update location.

To check for updates programmatically

With a project selected in Solution Explorer, on the Project menu, click Properties.

Click the Publish tab.

Click the Updates button to open the Application Updates dialog box.

In the Application Updates dialog box, make sure that the The application should check for updates check box is cleared. (Optionally, you can select this check box to check for updates programmatically and also let the ClickOnce runtime check for updates automatically.)

In the Update location field, enter the update location with a fully qualified URL, using the format http://Hostname/ApplicationName, or a UNC path using the format \\Server\ApplicationName, or click the Browse button to browse for the update location. The update location is where the application will look for an updated version of itself.