ClickOnce Getting Started Sample

ClickOnce is pretty simple to get going once you know where to click (no pun intended.)  Here’s a down and dirty, quick start guide on how to implement ClickOnce in your application:

First, create a sample application in Visual Studio.  The attached sample is a WPF application using VS 2008.  ClickOnce configuration is managed through the project property pages so right-click on the project and click properties (or type ALT+ENTER) to access the properties pages.

image

Under the Signing Tab, Select Sign the ClickOnce manifest.  When you first publish, a temporary key (named [APPNAME]_TemporyKey.pfk) will be created and added to your the project.  Additionally, the temporary certificate information will be generated and displayed in the Certificate textarea.image

Under the Security Tab, Select Enable ClickOnce Security Settings.  Also select This is a full trust application.  If you wish to go with the partial trust option, I would recommend configuring your permissions per the Calculate Permissions option. 

Note, an empty WPF application (single XML windows with no logic) must be run as a full trust application according to the Calculate imagePermissions analyzer.  A similar Windows Application (single form with no logic,) in comparison, can be run with partial trust. 
 
Under the Publish Tab, enter a Publish Location.  You may, for example, provide a locally hosted website.  If the website doesn’t exist, it will be created – assuming appropriate permissions are granted to the logged in user.  Be sure to select imageThe application is available offline as well. 

Open the Updates… dialogue. Check The application should check for updates.  Keep the default which states the application will check for updates before it starts.  Click OK.

Open the Options… dialogue. Under Description, provide a Publisher and Product name.  Under Deployment, provide a imageDeployment web page.  I recommend “Publish.htm” and check Automatically generate deployment web page after publish.  Under Manifests, you may wish to select Create desktop shortcut. Click OK.

Your basic ClickOnce configuration is now in place and it is time to test.  Compile and publish the application.  Publishing many be done through the Publishing Tab’s Publishing Wizard, or via the Publishing imageNow option.  Alternatively, you may use the Publish option under the Build Menu. 

The Publish action will copy your compiled application to the publish location and render publish.htm page in your default browser.  Notice the application name, version and publisher is displayed along with an Install link.  imageClick on the Install link to kick off the download and installation of the application. You will be potentially be prompted with a security warning along with the request to install.  Continue with the installation.  Once complete, the application will launch automatically.  The application may be launched via the application shortcuts going forward. 

That’s it. The downloadable sample application doesn’t do much of anything. It merely demonstrates the installation of a WPF application using ClickOnce technology.  You may uninstall as you would any traditional application. 

Download Sample ClickOnce WPF Project:ClickOnceSample.zip

References:

See ClickOnce In Action:

Comments

  1. Hi,

    I have an application which is to be installed on different sys pointing to seperate DBs on their Local system. Is there any way i can use click once technology to run the Installation which can restore DB backup once it is installed.

closed