<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>ClickOnce</title>
        <link>http://geekswithblogs.net/vitus/category/10029.aspx</link>
        <description>ClickOnce</description>
        <language>ru-RU</language>
        <copyright>Vitus</copyright>
        <managingEditor>vitus@movaxbx.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Working with ClickOnce: some tips</title>
            <link>http://geekswithblogs.net/vitus/archive/2009/05/04/working-with-clickonce-some-tips.aspx</link>
            <description>&lt;p&gt;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.&lt;/p&gt;  &lt;h4&gt;&lt;strong&gt;1. Making offline-installer&lt;/strong&gt;&lt;/h4&gt;  &lt;p&gt;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.    &lt;br /&gt;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:&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image12" border="0" alt="image12" src="http://geekswithblogs.net/images/geekswithblogs_net/vitus/WindowsLiveWriter/WorkingwithClickOncesometips_D714/image12_3.png" width="326" height="251" /&gt;&lt;/p&gt;  &lt;p&gt;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.    &lt;br /&gt;And when we choose "Download prerequisites from the same location as my application" radio-button, we get full installation package.     &lt;br /&gt;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.     &lt;br /&gt;Solution of problem contains in &lt;a href="http://download.microsoft.com/download/A/2/8/A2807F78-C861-4B66-9B31-9205C3F22252/VS2008SP1Readme.htm#General%20Issues" target="_blank"&gt;Readme to VS2008 SP1&lt;/a&gt; :) 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 :)&lt;/p&gt;  &lt;h4&gt;&lt;strong&gt;2. IsFirstRun&lt;/strong&gt;&lt;/h4&gt;  &lt;p&gt;For example, we need to do something only once after application is installed. We have &lt;a href="http://msdn.microsoft.com/en-us/library/system.deployment.application.applicationdeployment.isfirstrun.aspx" target="_blank"&gt;IsFirstRun&lt;/a&gt; static property of ApplicationDeployment class. We can use it:&lt;/p&gt;  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;   &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(ApplicationDeployment.IsNetworkDeployed &amp;amp;&amp;amp; &lt;/pre&gt;

  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                ApplicationDeployment.CurrentDeployment.IsFirstRun)&lt;/pre&gt;

  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;

  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// do something&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Here I check, is my application installed, after that I can check for the first run. But IsFirstRun flag is &lt;strong&gt;false&lt;/strong&gt;, when application is updated, and this is an error. Solution is simple - I define bool application setting:&lt;/p&gt;

&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image10" border="0" alt="image10" src="http://geekswithblogs.net/images/geekswithblogs_net/vitus/WindowsLiveWriter/WorkingwithClickOncesometips_D714/image10_3.png" width="414" height="40" /&gt;&lt;/p&gt;

&lt;p&gt;Default value is &lt;strong&gt;true&lt;/strong&gt;. And then I use it:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (ApplicationDeployment.IsNetworkDeployed &amp;amp;&amp;amp; Settings.Default.IsFirstRun)&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// do something&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    Settings.Default.IsFirstRun = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    Settings.Default.Save();&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;h4&gt;&lt;strong&gt;3. Proxy server side effects&lt;/strong&gt;&lt;/h4&gt;

&lt;p&gt;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. &lt;/p&gt;

&lt;p&gt;That's all. I'll complete my post later, if remember or find any "features".&lt;/p&gt; &lt;img src="http://geekswithblogs.net/vitus/aggbug/131712.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Vitus</dc:creator>
            <guid>http://geekswithblogs.net/vitus/archive/2009/05/04/working-with-clickonce-some-tips.aspx</guid>
            <pubDate>Mon, 04 May 2009 09:18:43 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/vitus/comments/131712.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/vitus/archive/2009/05/04/working-with-clickonce-some-tips.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/vitus/comments/commentRss/131712.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>
