Application Deployment
Once you've packed all of the features that WPF supports into
your application, you still have the challenge of getting it to your users. As
part of its effort to merge the best of Windows and the Web, WPF leverages the
ClickOnce application-deployment support built
into .NET 2.0 to enable WPF applications to be deployed over the Web.
You can deploy your WPF application to a web server for their
enjoyment by right-clicking on the project in the Solution Explorer and
choosing the Publish option, which brings up the Publish Wizard, which asks you
where and how you would like to publish the output of your project.
If you choose the defaults, you'll have chosen to publish a
ClickOnce "local install" application to the local machine's web server. A
successful publication will bring up a Visual Studio-generated HTML file for
you to test your application, as shown in
Figure 1-23.
This version of publish.htm uses the default settings,
including the name of the company of the author who built this sample (which is
only coincidently the name of the company that developed WPF), the project name
of the application, and the version number for the initial publication of this
application.
Clicking on this link deploys the application. The first step is
downloading the files that make up the application, as shown in
Figure 1-24.
Once the files are downloaded, they're checked for a certificate
signature from a known publisher. Since this requires nondefault settings, what
you'll see is Figure 1-25.
The Security Warning dialog is shown when the user hasn't
already awarded a publisher the permissions to take certain liberties on their
computer or when the publisher isn't known at all. If the user presses the
Cancel button at this point, no potentially "evil" code has been downloaded or
executed. If the user presses the Install button, the application's files are
put into the right place, a Start menu folder is established and the
application itself is executed, just like a normal WPF application.
If the user can establish a connection to the web server,
subsequent runs will detect application updates and offer to upgrade the user's
copy of the application, providing them a way to roll back to previous versions
(or even uninstall completely) using the Add or Remove Control Panel. Also,
even if there is no network connection, since the application is locally
installed, no connection is needed to launch the application from the Start
menu.
Those of you with trusting souls will now be thinking to
yourself, "Wow! What an easy way to get bits out to my users and keep them up
to date with the latest features and bug fixes!" and you'd be absolutely right;
that's exactly what ClickOnce was designed for and why WPF was specially
engineered to work with it.
Those of you with suspicion in your hearts will now be thinking,
"Wow! What a great way for naughty men to format my hard drive, send
incriminating email to my boss in my name, or reset my Minesweeper high
scores!" and you'd be right, too except that ClickOnce applications run in the
.NET Code Access Security sandbox.
 |
As of this writing, WPF locally installed ClickOnce
applications require "full trust" (which is .NET-speak for "I have always
depended on the kindness of strangers"), but this will not be the case for the
release of WPF 1.0.
|
|
This has been the quickest possible overview of ClickOnce
deployment of WPF applications. For much more detail on WPF application
deployment, including express applications that are deployed over the Web and
hosted in the browser, please read
Chapter 10.
|