Section 6.9. Deploy Your Application with ClickOnce


6.9. Deploy Your Application with ClickOnce

One of the driving forces behind the adoption of browser-based applications is the fact that organizations don't need to deploy their applications to the client. Most companies are willing to accept the limitations of HTML in order to avoid the considerable headaches of distributing application updates to hundreds or thousands of users.


Note: Want the functionality of a rich client application with the easy deployment of a web application? ClickOnce offers a new solution for deploying your software.

Deploying a .NET client application will never be as straightforward as updating a web site. However, .NET 2.0 includes a new technology called ClickOnce that simplifies deployment dramatically.

6.9.1. How do I do that?

ClickOnce includes a few remarkable features:

  • ClickOnce can automatically create a setup program that you can distribute on a CD or launch over a network or through a web page. This setup program can install prerequisites and create the appropriate Start menu icons.

  • ClickOnce can configure your application to check for updates automatically every time it starts (or periodically in the background). Depending on your preference, you can give the user the option of downloading and running the new updated version, or you can just install it by force.

  • ClickOnce can configure your application to use an online-only mode. In this case, the user always runs the latest version of your application from a web page URL. However, the application itself is cached locally to improve performance.

ClickOnce is tightly integrated with Visual Studio 2005, which allows you to deploy a ClickOnce application to a web site using the Project Publish menu command.

The following steps take you through the process of preparing your project for publication:

  1. Using Visual Studio 2005, create a new project. A good choice is a Windows Forms application. Before continuing, save the project.

  2. Choose Build Publish [ProjectName] (or right-click your project in the Solution Explorer and choose Publish). This launches the Publish wizard, which gives you a chance to specify or change various settings.

  3. The first dialog page of the Publish wizard (the "Where do you want to publish" dialog) prompts you to choose the location where you will publish the files to be deployed (see Figure 6-3). This location is the file path or the virtual directory on your web server where you want to deploy the application. For a simple test, use a URL that starts with http://localhost/ (which refers to the current computer). Click Next to continue.


    Tip: When Visual Studio publishes the application, it will automatically create a subdirectory named publish in the current application directory, and it will map this to the virtual directory path you've selected.

    Figure 6-3. Choosing a deployment directory


  4. Next, choose the install mode (see Figure 6-4) by clicking one of the buttons on the "Will the application be available offline" dialog page. Select "Yes, this application is available online or offline." This way, the setup will add application icons to the Start menu. If you choose "No, this application is only available online," the user will only be able to run it by surfing to the virtual directory to which it's been published. Click Next to continue.

    Figure 6-4. Choosing the install mode


  5. The Publish wizard now displays a summary of your settings. Click Finish to publish it. (You can publish an updated version at any time by selecting Build Publish [ProjectName] from the menu.)

Once the wizard completes, the automatically generated ClickOnce web page is launched, as shown in Figure 6-5. Using this page, a user can click to download and install your application. Try it out by clicking the Install [AppName] link.

Figure 6-5. The ClickOnce installation page


The installation runs without any messages, unless it needs to ask for user consent. For example, before the installation can add an icon to the Start menu, it needs to prompt the user.

Best of all, now that the application is in place, you can make use of its automatic update ability. To test this out, return to the application in Visual Studio .NET and change the main form (perhaps by adding a new button). Then, increment the version number of the application. (To do this, double-click the My Project item in the Solution Explorer, select the Application tab, and click the AssemblyInfo button. A dialog box will appear that lets you set assembly metadata, including the version number.) Finally, republish the application.

When a new version is available on the server, client applications will update themselves automatically, based on their update settings. If you run the installed sample application, it checks for updates when it starts. In this case, it will detect the new version and prompt you to install the update.


Warning: The ClickOnce plumbing has been tweaked and refined continuously during the beta cycle. In some builds of Visual Studio, you may encounter an error when you try to publish a project using ClickOnce. Unfortunately, there aren't any workarounds.

6.9.2. What about...

...computers that don't have the .NET Framework 2.0 installed? These machines can't download and install a ClickOnce application automatically. However, when they surf to the ClickOnce installation page, they will see a link that will install the required prerequisites. There are a number of other approaches you can pursue to get .NET 2.0 installed on the client ahead of time. One easy choice is to use the Windows Update feature (surf to http://windowsupdate.microsoft.com from the client computer).

6.9.3. Where can I learn more?

There are a number of articles that discuss the ClickOnce technology in much greater detail. For more information, you may want to refer to the book Essential ClickOnce (Addison Wesley, forthcoming), or the introduction from MSDN magazine at http://msdn.microsoft.com/msdnmag/issues/04/05/ClickOnce. You can also find a great deal of information in the MSDN help library, and online at http://msdn.microsoft.com/clickonce.



Visual Basic 2005(c) A Developer's Notebook
Visual Basic 2005: A Developers Notebook
ISBN: 0596007264
EAN: 2147483647
Year: 2006
Pages: 123

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net