Geeks With Blogs


Vitaly Dilmukhametov

ClickOnce is a useful deployment system, which consist of many interesting features, such as easy deployment and updating. This technology is introduced long ago, and it's good-described. I want to stop on some tips, which can help you.

1. Making offline-installer

ClickOnce offer some mechanism for installing prerequisite software, before installing our application. It may be MS .NET Framework of necessary version, SQL Server Compact Edition, etc.
For example, we have WPF application, which use SQL Compact. In the list of available prerequisites we choose 3 items: Windows Installer 3.1, MS .NET FX 3.5SP1, SQL Server Compact 3.5:


How we can see, first radio button is selected. It's means, that all prerequisite software will be downloaded from vendor's website, and installed to the target computer. So, we need access to the internet.
And when we choose "Download prerequisites from the same location as my application" radio-button, we get full installation package.
In the real life I had some troubles with offline-installer. Some of my customers told me, that they can't install MS .NET 3.5SP1 on the computers, which is not connected to the internet. And the connected machines consumed some traffic during installation.
Solution of problem contains in Readme to VS2008 SP1 :) This document contains detailed description, how to prepare computer to creating offline ClickOnce installer, and how to avoid need  the internet for installing MS .NET 3.5SP1. Read “Enable Samesite for the .NET Framework 3.5 SP1 bootstrapper package” attentively :)

2. IsFirstRun

For example, we need to do something only once after application is installed. We have IsFirstRun static property of ApplicationDeployment class. We can use it:

if(ApplicationDeployment.IsNetworkDeployed && 
    // do something

Here I check, is my application installed, after that I can check for the first run. But IsFirstRun flag is false, when application is updated, and this is an error. Solution is simple - I define bool application setting:


Default value is true. And then I use it:

if (ApplicationDeployment.IsNetworkDeployed && Settings.Default.IsFirstRun)
    // do something
    Settings.Default.IsFirstRun = false;

3. Proxy server side effects

And one more issue: I upload new version to server, then click on the update button. And then I get an error: updating, for example, to version 3.1, and server send installation files of version 3.0, and updating process fail. The reason is in the caching proxy server, which is used in the organization. When I clean the cache, all is ok.

That's all. I'll complete my post later, if remember or find any "features".

Posted on Monday, May 4, 2009 3:18 PM ClickOnce , Deployment , Installer | Back to top

Comments on this post: Working with ClickOnce: some tips

# re: Working with ClickOnce: some tips
Requesting Gravatar...

Thanks for your article. I wonder what happens when the client machine is disconnected from the Internet the second time the application is run via the desktop shortcut? Does .NET Framework on the client machine simply ignores unavailability of the Internet and runs the application using the old stored files? Or does it collapse?
[I cannot test this since I'm working on my localhost machine]


Left by behrouz on Aug 20, 2009 2:49 PM

# re: Working with ClickOnce: some tips
Requesting Gravatar...
Hi, Behrouz!

Thank you for your reply! If you succesfully install prerequisites and your application, ClickOnce runtime don't need any Internet connections anymore. Your app executable files installed locally and you can use it.
Of course, if you want to update your installed app to the new version, and updated installation files located on some server in the Internet, you must have Internet available.

P.S. sorry for delay with answer
Left by Vitaly Dilmukhametov on Aug 28, 2009 5:01 AM

Your comment:
 (will show your gravatar)

Copyright © Vitus | Powered by: