Print | Contents | Close |

ClickOnce Applications in Visual Studio 2005

Learning objective

After completing this topic, you should be able to recognize how to deploy and configure ClickOnce applications in Visual Studio 2005.

1. Configuring ClickOnce

ClickOnce is a new technology added to Visual Studio 2005 that enables you to deploy Windows applications as easily as standard web applications.

Once you've deployed an application, ClickOnce enables users to install it or to use the application remotely, depending on the settings you've chosen. It also manages updates to the application after you've deployed it.

No administrative rights are required for ClickOnce applications.

You can configure ClickOnce properties to determine the features of any application published through it and to check for new versions before or after the application runs.

Most of the settings you will need to configure are related to publishing and security.

Suppose you want to publish the Windows Application template so that users can install it on their systems online. To do this, you first need to access settings for opening the project.

You select View - Solution Explorer from the main menu.

Alternatively, you press Alt+V, P.

The Solution Explorer tabbed page lists project files.

Note

One difference from Visual Studio 2003 is that Visual Studio 2005 hides the bin, Resources, and other folders for a project. To view hidden files and folders, you simply click the Show All Files icon.

You select ClickOnceAPIs and click the Properties icon.

The ClickOnceAPIs tabbed page enables you to configure ClickOnce properties in several categories for the application. It opens by default on the Application node, and displays general application property settings.

To view the ClickOnce settings for publishing the application, you click the Publish node.

The Publish interface provides user configuration options.

In the Publish Location section, you need to specify the directory in which the application will be published. The default location is http://localhost/'Application Name'. This can be given as a web site, an FTP server, or a file path.

If the location from which users will install applications is not the same as this address, you need to specify the correct address in the Installation URL text box.

In the Install Mode and Settings section, you need to specify whether the application will be available online only, or whether it will be available both online and offline. This decision is based on the purpose of the application.

The Publish Version section contains text boxes for specifying the major, minor, build, and revision numbers of the application version. You can set these manually, but the default option is for them to be incremented automatically.

In this case, you want to accept the default localhost publishing location, but you want to specify that the application should be available online only.

To do this, you select the The application is available online only radio button.

ClickOnce applications that are installed exclusively for online use are available to just one active user at a time. If more than one person attempts to access the application simultaneously, a separate installation is required for each person.

Now you want to check the permissions on the application.

So you click the Security node.

The Security tabbed page provides options for specifying the permissions needed for the application to run.

To enable the permissions, you select the Enable ClickOnce Security Settings checkbox.

Two radio buttons now become active. Accepting the default option creates a full trust application with all the default permissions. Selecting the second option creates a partial trust application, where you add or remove specific permissions.

In this case, you want to check the permissions that have been set and find out if any new ones are required.

To do this, you select the This is a partial trust application radio button and click the Calculate Permissions button.

The Calculate Permissions feature determines the permissions required by the program depending on the publishing options. The calculation lists the permissions that the application already has, that it does not need, and that need to be included.

To save the changes, you click the Save icon in the toolbar.

Question

Suppose you want to publish an application to a directory on the local server, and you want this application to be available for online use only. What must you specify in the Publish node of the application's properties to choose this setting?

Options:

  1. A publishing location file path
  2. The application files needed by the application
  3. The availability of the application as online only
  4. The version of the application to be published

Answer

To publish an application to a local server for online use, you need to enter the location's file path and specify that the application should be available for online use only.

Option 1 is correct. The application will be published to a directory on a local server, so you need to specify this file path.

Option 2 is incorrect. Specifying the application files plays no role in setting the publishing location or its availability.

Option 3 is correct. The application must be available online only, so this needs to be specified in the Install Mode and Settings section of the Publish page.

Option 4 is incorrect. The Publish Version specifies the major, minor, build, and revision numbers of the application version. It is updated automatically by default and plays no role in determining publishing location or availability.

Question

Suppose you want to check which permissions users will need to access and run an online application you publish using ClickOnce. You've already accessed the Publish properties of ClickOnce for the application.

How do you check the required permissions?

Options:

  1. Click Security, select Enable ClickOnce Security Settings, and click the Calculate Permissions button
  2. Click Security, select Enable ClickOnce Security Settings, select This is a partial trust application, and then click the Calculate Permissions button
  3. Click Signing, select Enable ClickOnce Security Settings, select This is a full trust application, and then click the Calculate Permissions button

Answer

To check the required permissions, you click Security, select Enable ClickOnce Security Settings, select This is a partial trust application, and then click the Calculate Permissions button.

2. Publishing a ClickOnce application

You can use ClickOnce to publish a Windows application to a web site, a File Transfer Protocol (FTP) server, a network share, or a directory on a local server.

To do this, you open the application you want to publish in Visual Studio. You then launch the Publish Wizard and use it to publish the application.

Using the Publish Wizard, you need to specify

Applications configured for offline use are installed on users' computers, whereas those for online use run directly from the publishing location.

Suppose you want to publish the Windows Application template so that users can install it on their systems offline. To do this, you first need to access settings for opening the project.

You select View - Solution Explorer from the main menu.

Alternatively, you press Alt+V, P.

The Solution Explorer tabbed page lists project files.

You select ClickOnceAPIs and click the Properties icon.

The ClickOnceAPIs page opens by default on the Application node, and displays general application property settings.

To view the ClickOnce settings for publishing the application, you click the Publish node.

In this case, you want to accept the default localhost publishing location, but you want to specify that the application should be available offline as well.

You select the The application is available offline as well radio button.

The application will now be available for offline and online use.

Now you want to publish the application for offline use utilizing ClickOnce.

You select Build - Publish ClickOnceAPIs from the main menu.

Alternatively, you press Alt+B, H.

The Publish Wizard provides a text box in which you need to specify the publishing location of the application.

In this case, you want to accept the default publishing location, so you click Next.

On the "Will the application be available offline?" screen, you need to specify how the application must be made available to users.

You want to make the application available both online and offline so that users can install it if they choose to, so you click Next to accept the default selection.

The Ready to Publish page of the wizard lists the location to which the application will be published, and you click Finish to publish the application.

Question

Suppose you want to publish an application to be available online only. You've already opened the application in Visual Studio.

How do you open the wizard that allows you to publish an application, and specify the online only option?

Options:

  1. Select Project - Publish ClickOnceAPIs, click the Browse button, select No, this application is only available online, and click Next
  2. Select Build - Publish ClickOnceAPIs. Click Next, select No, this application is only available online, and click Next
  3. Select Build - Build ClickOnceAPIs, click No, this application is only available online and click Next

Answer

To specify that ClickOnceAPIs must be online only, you select Build - Publish ClickOnceAPIs and click Next. Then you select No, this application is only available online, and click Next.

Question

What do you need to specify when you publish a ClickOnce application?

Options:

  1. The files associated with the application
  2. The online and offline availability
  3. The publication location
  4. The update options

Answer

When you publish a ClickOnce application, you need to specify the application's online and offline availability and the publication location.

Option 1 is incorrect. Application files are automatically associated with the application, although you can choose to alter the list of associated files.

Option 2 is correct. You need to specify whether the published application must be available for both online and offline use, or for online use only.

Option 3 is correct. You need to specify the location to which you want to publish the application, or to accept the default location on the local host. You can choose to publish to a web site, an FTP server, or a file path you specify.

Option 4 is incorrect. Update options specify whether updates should be automatic or prompted. Although you can alter these option settings using the application's Publish properties, you don't need to do this to publish the application.

3. Installing a ClickOnce application

You can install a ClickOnce application directly from the site that it is located on.

After users install a published application you've chosen to make available offline, default settings cause ClickOnce to automatically check for application updates whenever users launch the application. It then prompts the users, who can decide whether to install the updates.

Online applications update automatically, without requiring user intervention.

It is possible to alter this by programming custom update behavior for your application, using the ApplicationDeployment and DeploymentManager classes of the System.Deployment namespace.

Suppose you want to install an application published online to your network. To do this, you simply open the site and perform the installation.

You click the Install button.

The Application Install - Security Warning dialog box asks whether you are sure you want to install the application.

To proceed, you click Install.

The application opens automatically once it has downloaded.

Question

In which ways does ClickOnce manage updates to applications?

Options:

  1. It automatically checks that offline application versions match the online version
  2. It prompts offline users when updates are available
  3. It updates offline applications automatically
  4. It updates online applications automatically

Answer

ClickOnce prompts offline application users when updates are available, and updates online applications automatically.

Option 1 is incorrect. ClickOnce alerts offline users once application updates are available. It doesn't, however, automatically ensure that offline versions include the same updates as an online version.

Option 2 is correct. When it detects available updates, ClickOnce prompts offline users. These users can then choose to install the updates.

Option 3 is incorrect. When updates for an application become available, ClickOnce alerts users of offline versions of the application. It doesn't, however, automatically download and implement the updates.

Option 4 is correct. ClickOnce automatically updates online applications, as soon as it detects that updates are available. This process doesn't require user intervention.

Question

Suppose you want to ensure that users can only access an application that is fully updated.

How do you do this?

Options:

  1. Configure ClickOnce to update the offline application automatically
  2. Make the application available offline only
  3. Make the application available online only
  4. Update and republish the application each time updates become available

Answer

To ensure that users access only updated versions of the application, you need to make the application available online only.

Option 1 is incorrect. ClickOnce automatically prompts users when updates for offline applications they launch become available. It doesn't, however, automatically install these updates.

Option 2 is incorrect. ClickOnce doesn't enable you to publish an application so that it's available offline only. Also, it doesn't automatically update offline applications.

Option 3 is correct. ClickOnce automatically updates online applications you've used it to publish. Ensuring that users can't use the application offline therefore ensures that they can access only updated versions of the application.

Option 4 is incorrect. Manually updating and republishing the application won't automatically update earlier versions of the application that users have installed on their systems, if you initially set the application to be available offline.

Summary

To publish an application using ClickOnce, you open the application and then use the Publish Wizard. In the wizard, you specify the publish location and whether the application must be available online only, or online and offline.

You can configure ClickOnce properties to determine the features of an application you publish and to check required permissions for running the application.

A user can install a ClickOnce application available for offline use from the location to which you published it.