Visual Studio 2005 makes the deployment of Windows applications to your users extremely easy and painless, all through a new feature known as Click-Once.
ClickOnce was designed specifically to ease the deployment of smart clients.
A smart client is basically a Windows application that leverages the system's local resources and is able to intelligently connect to distributed data sources (such as web services) as and when needed.
The Library Application that you've been building in this chapter is an example of a smart client. While today a lot of companies are deploying web applications (due to their ubiquitous access), network latencies and server delays are some of the problems that are preventing developers from reaping the full benefits of the Web. Common frustrations over web applications include slow response time from web sites and limited functionality (due to the stateless nature of the HTTP protocol). As such, a smart client aims to reap the benefit of the rich functionality of the client (Windows) while at the same time using the power of web services in the backend.
To illustrate how ClickOnce works, you will publish the Library Application (LibraryApp) that you have written and see how easy it is to deploy it using a web server. Furthermore, ClickOnce has the added benefit of ensuring that applications that you deploy will automatically check for the latest update (you can configure the application to check every time before it runs, or check at regular time intervals) on the server, if one is available, as you'll see in "Automatic Updating," later in this capter.
4.3.1. Publishing the Application
You can now publish (deploy) a Windows application through a disk, shared folder, FTP server, or web server, and automatically ensure that users are always using the latest version of the application.
To run the ClickOnce Publish Wizard, go to Build Publish LibraryApp on the Visual Studio menu, as shown in Figure 4-32. The "Where do you want to publish dialog box will appear.
Figure 4-32. Publishing the LibraryApp Windows application
The "Where do you want to publish" dialog box gives you four options for where to publish the application: disk, shared folder, FTP server, or web server. For this project, you will publish the application through the IISweb server (see the sidebar "Installing IIS on Your Computer" on how to install IIS on your Windows XP computer).
In the "Specify the location to publish the application" text box, create a directory for the application by entering the following link: http://localhost/LibraryApp (see Figure 4-33). Click Next. The "Will the application be available offline?" dialog will appear.
Localhost is the name of the web server installed in your local computer.
Figure 4-33. Specifying the path to publish the folder
ClickOnce allows the user to install an application locally on the client, or to download every time it is needed. In the "Will the application be available offline?" dialog, select "Yes," as shown in Figure 4-34, and then click Next. The "Ready to Publish!" dialog will appear.
Figure 4-34. Choosing the mode in which the application should be run
That's it! You are now ready to publish the application from your web server. In the "Ready to Publish!" dialog shown in Figure 4-35, click Finish to create the web page that users will link to in order to install the application.
Figure 4-35. The wizard is ready to publish the application
You should see the web page shown in Figure 4-36. Your users can now use the URL for that page to install the application on their own machines.
Figure 4-36. Installing the application through the web server
To install the application on your own machine, click the launch link in the page.
Click the Install button to install the prerequisites, if your machine does not have them.
You will be prompted with a security warning such as the one shown in Figure 4-37. Click Install to install the application onto your machine.
You can eliminate this security warning by setting the relevant security policy. Refer to the MSDN Help Topic "Code Access Security for ClickOnce Applications" for more information. Also, check out the help topic "How to: Sign ClickOnce Application and Deployment Manifests" (http://msdn2.microsoft.com/library/che5h906(en-us,vs.80).aspx) for more information.
Figure 4-37. Installing the application
You will now see that the LibraryApp application is launched automatically. Alternatively, you can launch the LibraryApp application from Start Programs LibraryApp LibraryApp.
The ClickOnce installation does not require you to have administrator rights to install the application.