Overview of Click Once

ClickOnce is a new deployment technology that allows you to create self-updating applications that can be installed from a variety of sources and require minimal user interaction. Any Windows Forms application can be published as a ClickOnce application. You can use ClickOnce to create applications that are deployed from a Web site, a file share, or a CD-ROM. You can configure ClickOnce applications to be run only while the user is online or while the user is offline.

You can configure ClickOnce applications to be self-updating. When configured for updates, ClickOnce applications will automatically check for updates at the location from which they were installed and will automatically download updates if they exist.

ClickOnce applications are isolated from the rest of the system. Because they are completely self-contained, they share no components with the rest of the applications installed on the computer and run no risk of breaking other applications' installations. ClickOnce applications, by default, run in the Internet or intranet security zones when run from the remote location, or under full trust if installed on the local computer. Additional permissions, if required, can be requested by the application, giving the installer the opportunity to grant or deny those permissions.

Publishing a ClickOnce Application

You can configure the properties for a ClickOnce application by right-clicking the solution in Solution Explorer, choosing Properties, and then selecting the Publish tab. This displays the Publish properties page, shown in Figure 15-1.

Figure 15-1 The Publish properties page

You can configure the properties for your deployment strategy in this window. Once your properties have been configured, you can publish your application by clicking the Publish Now button.

Specifying the Publishing Location You can specify the publishing location in the Publishing Location combo box. This should be a file path, a network share, a Hypertext Transfer Protocol (HTTP) address, or a File Transfer Protocol (FTP) address. This is generally the address to which users will go to install the application. You can optionally specify an installation URL for users to install the application from. This is only needed if the ClickOnce application is staged on a different server than the installation location.

Configuring the Install Mode You can configure a ClickOnce application to be available only when the user is online or when the user is online or offline. By selecting The Application Is Available Online Only in the Install Mode And Settings group of the Publish properties page, you require the application to be run directly from the location specified in the Publishing Location combo box. You can also select The Application Is Available Offline As Well to make the application available offline. In this case, the application will be copied to the local computer and added to the Start menu and the Add/Remove Programs box in the Control Panel.

Configuring Automatic Updates You can configure ClickOnce applications to automatically check for updates. By clicking the Updates button in the Publish properties page, you can open the Application Updates dialog box, shown in Figure 15-2.

Application Updates

0 The application should check for updates Choose when the application should check for updates: ® After the application starts

Choose this option to speed up application start time. Updates will not be installed until the next time the application is run.

O Before the application starts

Choose this option to ensure that users who are connected to the network always run with the latest updates.

Specify how frequently the application should check for updates: 0 Check every time the application runs O Check every: | day(s) v |

0 Specify a minimum required version for this application Major: Minor: Build: Revision:

Update location (if different than publish location):

Figure 15-2 The Application Updates dialog box

To enable the application to check for updates, select the check box labeled The Application Should Check For Updates. Doing so enables the other options in the dialog box. You can specify when the application checks for updates by selecting either After The Application Starts or Before The Application Starts. If you select Before The Application Starts, the application will check for new updates every time the application is started. This ensures that the user is always running the most recent version, but it also takes more time at startup. If you select After The Application Starts, you can specify that the application check for updates every time it is run, or at a designated time interval, by choosing the appropriate option under Specify How Frequently The Application Should Check For Updates. You can also specify a minimum required version for the application, and you can specify a different location for updates if your updates will be hosting in a location other than the install location.

Configuring Required Permissions for a ClickOnce Application

By default, ClickOnce applications run from the Internet run in the Internet security zone, and ClickOnce applications run from a file share run in the intranet security zone. For some applications, you might require additional permissions for the application to run. You can configure ClickOnce permissions on the Security tab of the project properties pages. The Security page is shown in Figure 15-3.

Figure 15-3 The Security properties page

You can either manually select permissions to be granted to the application, or you can calculate the permissions required by the application and configure the application to request those permissions.

► To calculate permissions for a ClickOnce application

1. On the Security properties page, select the check box labeled Enable ClickOnce Security Settings.

2. Choose the radio button labeled This Is A Partial Trust Application.

3. Click the button labeled Calculate Permissions.

4. The permissions required by your application are added to the permissions that will be requested by your application upon install.

► To manually configure permissions for a ClickOnce application

1. On the Security properties page, select the check box labeled Enable ClickOnce Security Settings.

2. Choose the radio button labeled This Is A Partial Trust Application.

3. In the Permissions Required By The Application table, find the permission of interest.

4. In the Setting column, choose Include to include the permission as required or Exclude to not require the permission.

Note that any permissions not included in the zone permission set under which the application is installed must be approved by the user before installation is completed.

Installing a ClickOnce Application on a Client Computer

Installing a ClickOnce application is almost as simple as the name implies.

► To install a ClickOnce Application from a Web site

1. Navigate to the Publish.htm Web page for the ClickOnce application.

2. Click Install and follow the steps (if any) in the Install wizard.

► To install a ClickOnce Application from a file share

1. Navigate to the file share for the ClickOnce application.

2. Double-click Setup and follow the steps (if any) in the Install wizard.

Quick Check

1. To what locations can you publish a ClickOnce application?

2. How can you determine the required permissions for a ClickOnce application?

Quick Check Answers

1. You can publish a ClickOnce application to a file path, a network share, an HTTP address, or an FTP address.

2. You can determine the required permissions for a ClickOnce application by going to the Security properties page, enabling ClickOnce security settings, setting the application to partial trust, and clicking the Calculate Permissions button. The permissions required by the application will be calculated automatically.

Was this article helpful?

0 0

Post a comment