<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Aneef.Net &#187; .Net Installation.</title>
	<atom:link href="http://www.aneef.net/tag/net-installation/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.aneef.net</link>
	<description>Do it in .Net way &#124; Blogging about C#,ASP.Net, LINQ,WPF and .Net Technologies</description>
	<lastBuildDate>Mon, 24 May 2010 10:50:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>ClickOnce Application,Expired Certificates &amp; Public Key Token PART III &#8211; Pushing .net Framework 3.5</title>
		<link>http://www.aneef.net/2009/07/09/clickonce-applicationexpired-certificates-public-key-token-part-iii-pushing-net-framework-3-5/</link>
		<comments>http://www.aneef.net/2009/07/09/clickonce-applicationexpired-certificates-public-key-token-part-iii-pushing-net-framework-3-5/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 11:33:24 +0000</pubDate>
		<dc:creator>Aneef Fashir</dc:creator>
				<category><![CDATA[.Net Related]]></category>
		<category><![CDATA[ClickOnce]]></category>
		<category><![CDATA[Tricks & Tips]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[visual studio 2008]]></category>
		<category><![CDATA[.Net Installation.]]></category>
		<category><![CDATA[Certificate]]></category>
		<category><![CDATA[Check .Net Framework]]></category>
		<category><![CDATA[Registry]]></category>

		<guid isPermaLink="false">http://www.aneef.net/2009/07/09/clickonce-applicationexpired-certificates-public-key-token-part-iii-pushing-net-framework-3-5/</guid>
		<description><![CDATA[In the last few weeks I wrote 2 articles on how to resolve ClickOnce certificate expiration issues. you can find those articles here : ClickOnce Application,Expired Certificates &#38; Public Key Token PART I ClickOnce Application,Expired Certificates &#38; Public Key Token PART II During my work on this ClickOnce update, we decided to upgrade the application [...]]]></description>
			<content:encoded><![CDATA[<p>In the last few weeks I wrote 2 articles on how to resolve ClickOnce certificate expiration issues. you can find those articles here :</p>
<ol>
<li><a href="http://www.aneef.net/2009/06/11/clickonce-applicationexpired-certificates-public-key-token-part-i/">ClickOnce Application,Expired Certificates &amp; Public Key Token PART I</a>
<li><a href="http://www.aneef.net/2009/06/11/clickonce-applicationexpired-certificates-public-key-token-part-ii/">ClickOnce Application,Expired Certificates &amp; Public Key Token PART II</a> </li>
</ol>
<ol>During my work on this ClickOnce update, we decided to upgrade the application to target .net framework 3.5 sp1.</ol>
<ol>so I just set the target framework to 3.5 and set the required prerequisites (.net 3.5 SP1, and Windows Installer 3.1). and built the project and published it. and when I tried on a client machine which had .net framework 2.0, application got updated, prompted the uninstall message, and tried to launch the new ClickOnce application from the new URL, and BANG!. we get an error :</ol>
<ol><a href="http://www.aneef.net/wp-content/uploads/2009/07/image001.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image001" src="http://www.aneef.net/wp-content/uploads/2009/07/image001_thumb.jpg" width="286" height="142"></a></ol>
<ol>The Error Message Says :</ol>
<blockquote><p>Unable to install or run the application. The application</p>
<p>requires that assembly WindowsBase Version 3.0.0.0 be</p>
<p>installed in the Global Assembly Cache (GAC) first.</p>
</blockquote>
<p>Why is this ?, its because when we try to launch the new application URL we do this :</p>
<pre>DeploymentUtils.AutoInstall("&lt;Path toNewApplication.application&gt;");</pre>
<pre>&nbsp;</pre>
<p>we request for the application manifest. and it fails to launch the application because it doesn&#8217;t have the prerequisites. and now to force the new prerequisites the application should call the setup.exe in the Web Server instead of the manifest. now the question is, what if the user already have&nbsp; the .net Framework 3.5 SP1?, we don&#8217;t have to prompt the client to install them again by launching setup.exe, we just have to launch the manifest. To Serve both the above scenario we need to check if the client machine has .net framework 3.5 SP1, and depending on its availability we need to launch the manifest or the setup.exe. The existence of .net Framework can be obtained from the following registry location: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP <a href="http://www.aneef.net/wp-content/uploads/2009/07/image.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://www.aneef.net/wp-content/uploads/2009/07/image_thumb.png" width="544" height="216"></a> you can find out all the .net Frameworks installed and their service pack versions in this registry entry. Following are the locations of the main Net Frameworks:</p>
<table border="0" cellspacing="0" cellpadding="2" width="540">
<tbody>
<tr>
<td valign="top" width="128">Framework 1.1</td>
<td valign="top" width="411">Software\\Microsoft\\NET Framework Setup\\NDP\\v1.1.4322</td>
</tr>
<tr>
<td valign="top" width="128">Framework 2.0</td>
<td valign="top" width="411">Software\\Microsoft\\NET Framework Setup\\NDP\\v2.0.50727</td>
</tr>
<tr>
<td valign="top" width="128">Framework 3.0</td>
<td valign="top" width="411">Software\\Microsoft\\NET Framework Setup\\NDP\\v3.0\\Setup</td>
</tr>
<tr>
<td valign="top" width="128">Framework 3.5</td>
<td valign="top" width="411">Software\\Microsoft\\NET Framework Setup\\NDP\\v3.5</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>Now we can check if the required .net Framework is available in the client machine, and launch the application setup.exe or the manifest. to do this we need to programmatically check these registries. for this I used the attached code ( I Couldn&#8217;t find the original author, Credits goes to him/her) which I found from web and modified to avoid few bugs. you can add this code to your project and do the below check in your application to decide which file to be launched :</p>
<pre class="csharpcode">&nbsp;</pre>
<pre class="csharpcode"><span class="kwrd">string</span> FileToLaunch=<span class="str">@"/setup.exe"</span>;
<span class="kwrd">if</span> (FrameworkUtils.IsInstalled(FrameworkVersion.Fx35)

 &amp;&amp; FrameworkUtils.GetServicePackLevel(FrameworkVersion.Fx35) == 1)
          {
            FileToLaunch = <span class="str">@"/&lt;application manifest.application&gt;"</span>;
          }
            MessageBox.Show(<span class="str">"Your message here"</span>);
            <span class="kwrd">string</span> updateURL = DeploymentUtils.getUpdateURL();
            DeploymentUtils.UninstallMe();
            DeploymentUtils.AutoInstall(<span class="str">"https://"</span> + updateURL + FileToLaunch);
            Application.Exit();</pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<pre class="csharpcode">&nbsp;</pre>
<p>And that&#8217;s all, now the application will launch the setup.exe if the client doesn&#8217;t have the .net Framework 3.5 and prompt for its installation, or launch the application manifest if client has the framework installed.</p>
<p>Now you can solve your ClickOnce issue as well as upgrade .net Framework in client machine at the same time without problem.</p>
<p><a href="wp-content/uploads/2009/07/FrameworkUtil.cs.txt">Download FrameworkUtils.cs</a></p>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<img src="http://www.aneef.net/?ak_action=api_record_view&id=97&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.aneef.net/2009/07/09/clickonce-applicationexpired-certificates-public-key-token-part-iii-pushing-net-framework-3-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
