<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>Tip of the Day</title>
        <link>http://blog.colinmackay.net/category/19.aspx</link>
        <description>A short post, probably linking somewhere else, that gives a quick tip of the day to make development easier or more productive.</description>
        <language>en-GB</language>
        <copyright>Colin Angus Mackay</copyright>
        <managingEditor>colin.mackay@gmail.com</managingEditor>
        <generator>Subtext Version 1.9.0.27</generator>
        <item>
            <title>Tip of the Day #17: Duplicate input fields</title>
            <link>http://blog.colinmackay.net/archive/2010/02/06/Tip-of-the-Day-17-Duplicate-input-fields.aspx</link>
            <description>&lt;p&gt;Don’t allow duplicate input fields into your form.&lt;/p&gt;
&lt;p&gt;The other day I was trying to debug a bug in an application that I maintain. The code created a set of pagination buttons at the top of the page with previous and next buttons. At some point a request had come in that the buttons needed to be replicated at the bottom of the page. Since the HTML was being built up in a string and dumped in a literal control in the first place the developer that was tasked with making the change just dumped the string into two literal controls, the original at the top of the page, and the new one at the bottom of the page. The previous and next buttons use hidden input field to tell the application which actual page number the buttons correspond to. And these were now duplicated and as a result the previous and next buttons ceased to work.&lt;/p&gt;
&lt;p&gt;Here is an example of something similar:&lt;/p&gt;
&lt;pre&gt;&amp;lt;input id="first-hidden-field" value="123" type="hidden" name="some-name" /&amp;gt;&lt;br /&gt;&amp;lt;input id="submit-button" value="Submit" type="submit" /&amp;gt;&lt;br /&gt;&amp;lt;input id="second-hidden-field" value="456" type="hidden" name="some-name" /&amp;gt;&lt;/pre&gt;
&lt;p&gt;When the form fields are returned to the application and the field “some-name” is queried the result back is a combination of the two fields with the duplicate name. In this case:&lt;/p&gt;
&lt;pre&gt;string someName = Request.Form["some-name"];&lt;/pre&gt;
&lt;p&gt;will result in the value of “123,456” being stored in the string. Basically, it is the comma separated form of all the input fields with the given name.&lt;/p&gt;&lt;img src="http://blog.colinmackay.net/aggbug/11368.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2010/02/06/Tip-of-the-Day-17-Duplicate-input-fields.aspx</guid>
            <pubDate>Sat, 06 Feb 2010 22:01:38 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/11368.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2010/02/06/Tip-of-the-Day-17-Duplicate-input-fields.aspx#feedback</comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/11368.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Tip of the Day #16: NaN (Not a Number)</title>
            <link>http://blog.colinmackay.net/archive/2009/09/12/Tip-of-the-Day-16-NaN-Not-a-Number.aspx</link>
            <description>&lt;h3&gt;&lt;/h3&gt;  &lt;h3&gt;The Issue&lt;/h3&gt;  &lt;p&gt;If you want to detect if a double (System.Double) or float (System.Single) is “not a number” or NaN you cannot use something like this:&lt;/p&gt;  &lt;pre&gt;if (myDouble == double.NaN) { /* do something */ }&lt;/pre&gt;

&lt;p&gt;It will always be false.&lt;/p&gt;

&lt;p&gt;Sounds crazy? Try this:&lt;/p&gt;

&lt;pre&gt;double myDouble = double.NaN;
Console.WriteLine("myDouble == double.NaN : {0}", myDouble == double.NaN);&lt;/pre&gt;

&lt;p&gt;The result is:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;myDouble == double.NaN : False&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can see that myDouble was explicitly set the value of double.NaN, yet in the next line it is returning false.&lt;/p&gt;

&lt;h3&gt;The Solution&lt;/h3&gt;

&lt;p&gt;If you want to test for a floating point value being Not a Number you to use IsNan() which is a static method on System.Double and System.Single. Here is the first example re-written to use the static method. It will now work correctly:&lt;/p&gt;

&lt;pre&gt;if (double.IsNan(myDouble) { /* do something */ }&lt;/pre&gt;

&lt;p&gt;If we re-write our other example:&lt;/p&gt;

&lt;pre&gt;double myDouble = double.NaN;
Console.WriteLine("double.IsNaN(myDouble) : {0}", double.IsNaN(myDouble));&lt;/pre&gt;

&lt;p&gt;We get the expected result too:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;double.IsNaN(myDouble) : True&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;The Reason&lt;/h3&gt;

&lt;p&gt;According to Wikipedia: &lt;em&gt;In &lt;/em&gt;&lt;a href="http://en.wikipedia.org/wiki/Computing"&gt;&lt;em&gt;computing&lt;/em&gt;&lt;/a&gt;&lt;em&gt;, &lt;b&gt;&lt;a href="http://en.wikipedia.org/wiki/NaN"&gt;NaN&lt;/a&gt;&lt;/b&gt;, which stands for &lt;b&gt;N&lt;/b&gt;ot &lt;b&gt;a&lt;/b&gt; &lt;b&gt;N&lt;/b&gt;umber, is a value or symbol that is usually produced as the result of an operation on invalid input operands, especially in &lt;/em&gt;&lt;a href="http://en.wikipedia.org/wiki/Floating_point"&gt;&lt;em&gt;floating-point&lt;/em&gt;&lt;/a&gt;&lt;em&gt; calculations. For example, most &lt;/em&gt;&lt;a href="http://en.wikipedia.org/wiki/Floating_point_unit"&gt;&lt;em&gt;floating-point units&lt;/em&gt;&lt;/a&gt;&lt;em&gt; are unable to explicitly calculate the square root of negative numbers, and will instead indicate that the operation was invalid and return a NaN result. NaNs may also be used to represent missing values in computations.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It goes on to say: &lt;em&gt;A NaN does not compare equal to any floating-point number or NaN, even if the latter has an identical representation. One can therefore test whether a variable has a NaN value by comparing it to itself, thus if x = x gives false then x is a NaN code.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is why (double.NaN == double.NaN) always results in false. And it is also how the .NET framework detects the NaN value in the IsNan() method.&lt;/p&gt;

&lt;pre&gt;public static bool IsNaN(double d) 
{ 
    return (&lt;a&gt;d&lt;/a&gt; != &lt;a&gt;d&lt;/a&gt;); 
}&lt;/pre&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:3609ff88-8c57-41ac-a86f-d2f45b1ff1f4" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/NaN" rel="tag"&gt;NaN&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Not+a+Number" rel="tag"&gt;Not a Number&lt;/a&gt;,&lt;a href="http://technorati.com/tags/C%23" rel="tag"&gt;C#&lt;/a&gt;,&lt;a href="http://technorati.com/tags/.NET" rel="tag"&gt;.NET&lt;/a&gt;,&lt;a href="http://technorati.com/tags/floating+point+numbers" rel="tag"&gt;floating point numbers&lt;/a&gt;,&lt;a href="http://technorati.com/tags/float" rel="tag"&gt;float&lt;/a&gt;,&lt;a href="http://technorati.com/tags/double" rel="tag"&gt;double&lt;/a&gt;,&lt;a href="http://technorati.com/tags/System.Single" rel="tag"&gt;System.Single&lt;/a&gt;,&lt;a href="http://technorati.com/tags/System.Double" rel="tag"&gt;System.Double&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blog.colinmackay.net/aggbug/8988.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2009/09/12/Tip-of-the-Day-16-NaN-Not-a-Number.aspx</guid>
            <pubDate>Sat, 12 Sep 2009 12:21:15 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/8988.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2009/09/12/Tip-of-the-Day-16-NaN-Not-a-Number.aspx#feedback</comments>
            <slash:comments>10</slash:comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/8988.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Tip of the Day #15: Loop Performance</title>
            <link>http://blog.colinmackay.net/archive/2009/09/07/Tip-of-the-Day-15-Loop-Performance.aspx</link>
            <description>&lt;p&gt;When you look at the code it will probably seem somewhat obvious, but it is interesting how the same thought process isn’t necessarily there when actually developing the code, especially when under the pressure of a looming deadline.&lt;/p&gt;  &lt;p&gt;Take for example this snippet of code (from a fictitious hotel management system) that may have been run by a receptionist to print out the check in forms that customers of the hotel will fill in on their arrival.&lt;/p&gt;  &lt;pre&gt;List&lt;booking&gt; bookings = GetTodaysBookings();

foreach (Booking booking in bookings)
{
    PrintService service = GetLocalPrintService();
    service.PrintCheckInForm(booking);
}&lt;/booking&gt;&lt;/pre&gt;

&lt;p&gt;The method GetLocalPrintService() could be doing a multitude of things. It may simply be creating a new instance of the PrintService object, or it could be resolving a number of dependencies in order to set itself up to communicate with the local printer. But what ever it is doing, we don’t actually need a new instance of the service on each loop. The code will work just as well if we have just one instance that is re-used on each iteration of the loop.&lt;/p&gt;

&lt;p&gt;That being the case, the creation of the PrintService can be moved outside the loop so it is created only once, thus removing unnecessary work from the loop. The new code then looks like this:&lt;/p&gt;

&lt;pre&gt;List&lt;booking&gt; bookings = GetTodaysBookings();
PrintService service = GetLocalPrintService();

foreach (Booking booking in bookings)
{
    service.PrintCheckInForm(booking);
}&lt;/booking&gt;&lt;/pre&gt;

&lt;p&gt;As I said at the top, this is obvious. &lt;em&gt;Isn't it?&lt;/em&gt;&lt;/p&gt;&lt;img src="http://blog.colinmackay.net/aggbug/8922.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2009/09/07/Tip-of-the-Day-15-Loop-Performance.aspx</guid>
            <pubDate>Mon, 07 Sep 2009 07:55:56 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/8922.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2009/09/07/Tip-of-the-Day-15-Loop-Performance.aspx#feedback</comments>
            <slash:comments>11</slash:comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/8922.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Tip of the Day #14: A Step to PCI Compliance</title>
            <link>http://blog.colinmackay.net/archive/2009/09/06/Tip-of-the-Day-14-A-Step-to-PCI-Compliance.aspx</link>
            <description>&lt;p&gt;If you have a public facing website that accepts credit card payments from customers they you’ll be looking to become PCI compliant. This means you need to improve the security of your website to prevent attack and to prevent data being intercepted by third parties.&lt;/p&gt;  &lt;p&gt;SSL 2.0 is now seen as weak and insecure, yet IIS will by default accept connections from older browsers that want to use this. It can be turned off, but it isn’t obvious how to do that. Here’s &lt;a href="http://www.tourtools.com/media/downloads/disable-ssl-20-and-pct-10-iis"&gt;how to turn off SSL 2.0 on IIS&lt;/a&gt; or Microsoft Support has a reference on &lt;a href="http://support.microsoft.com/kb/187498/sl"&gt;How to disable PCT 1.0, SSL 2.0, SSL 3.0 or TLS 1.0 in IIS (Internet Information Services)&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;While many PCI auditing companies will tell you if you are using SSL 2.0 or any other weak techniques, the quick test to ensure the server is not serving pages using SSL 2.0 is to change the Advanced Options in Internet Explorer to only support SSL 2.0.&lt;/p&gt;  &lt;p&gt;&lt;a title="Internet Options 1 (SSL) by Colin  Angus Mackay, on Flickr" href="http://www.flickr.com/photos/colinangusmackay/3891739415/"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="Internet Options 1 (SSL)" src="http://farm4.static.flickr.com/3273/3891739415_8b04d18780_o.png" width="415" height="521" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;After that I went to a secure page in the site and got the following error message:&lt;/p&gt;  &lt;blockquote&gt;   &lt;h3&gt;Internet Explorer cannot display the webpage&lt;/h3&gt;    &lt;h5&gt;Most likely causes:&lt;/h5&gt;    &lt;ul&gt;     &lt;li&gt;You are not connected to the Internet. &lt;/li&gt;      &lt;li&gt;The website is encountering problems. &lt;/li&gt;      &lt;li&gt;There might be a typing error in the address. &lt;/li&gt;   &lt;/ul&gt;    &lt;h4&gt;What you can try:&lt;/h4&gt;    &lt;h6&gt;     &lt;p&gt;  &lt;br /&gt;Diagnose Connection Problems&lt;/p&gt;   &lt;/h6&gt;    &lt;h6&gt;     &lt;p&gt;  &lt;br /&gt;More information&lt;/p&gt;   &lt;/h6&gt;    &lt;p&gt;This problem can be caused by a variety of issues, including:&lt;/p&gt;    &lt;ul&gt;     &lt;li&gt;Internet connectivity has been lost. &lt;/li&gt;      &lt;li&gt;The website is temporarily unavailable. &lt;/li&gt;      &lt;li&gt;The Domain Name Server (DNS) is not reachable. &lt;/li&gt;      &lt;li&gt;The Domain Name Server (DNS) does not have a listing for the website's domain. &lt;/li&gt;      &lt;li&gt;If this is an HTTPS (secure) address, click Tools, click Internet Options, click Advanced, and check to be sure the SSL and TLS protocols are enabled under the security section. &lt;/li&gt;   &lt;/ul&gt;    &lt;p&gt;&lt;b&gt;For offline users&lt;/b&gt;&lt;/p&gt;    &lt;p&gt;You can still view subscribed feeds and some recently viewed webpages.      &lt;br /&gt;To view subscribed feeds &lt;/p&gt;    &lt;ol&gt;     &lt;li&gt;Click the Favorites Center button &lt;img border="0" src="res://ieframe.dll/favcenter.png" /&gt;, click Feeds, and then click the feed you want to view. &lt;/li&gt;   &lt;/ol&gt;    &lt;p&gt;To view recently visited webpages (might not work on all pages) &lt;/p&gt;    &lt;ol&gt;     &lt;li&gt;Click Tools &lt;img border="0" src="res://ieframe.dll/tools.png" /&gt;, and then click Work Offline. &lt;/li&gt;      &lt;li&gt;Click the Favorites Center button &lt;img border="0" src="res://ieframe.dll/favcenter.png" /&gt;, click History, and then click the page you want to view. &lt;/li&gt;   &lt;/ol&gt; &lt;/blockquote&gt;  &lt;p&gt;To ensure the site was working normally, I reset the settings to allow only support SSL 3.0 and TLS 1.0 and tried again. &lt;/p&gt;  &lt;p&gt;&lt;a title="Internet Options 2 (SSL) by Colin  Angus Mackay, on Flickr" href="http://www.flickr.com/photos/colinangusmackay/3892527696/"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="Internet Options 2 (SSL)" src="http://farm3.static.flickr.com/2487/3892527696_321b567282_o.png" width="415" height="521" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This time I got the page I was expecting. &lt;/p&gt;  &lt;p&gt;Note: You cannot use FireFox to perform this quick test as it does not support SSL 2.0.&lt;/p&gt;  &lt;p&gt;&lt;a title="Internet Options 3 (SSL/FF) by Colin  Angus Mackay, on Flickr" href="http://www.flickr.com/photos/colinangusmackay/3891742279/"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="Internet Options 3 (SSL/FF)" src="http://farm3.static.flickr.com/2427/3891742279_08451799f8_o.png" width="471" height="463" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blog.colinmackay.net/aggbug/8909.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2009/09/06/Tip-of-the-Day-14-A-Step-to-PCI-Compliance.aspx</guid>
            <pubDate>Sun, 06 Sep 2009 11:00:51 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/8909.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2009/09/06/Tip-of-the-Day-14-A-Step-to-PCI-Compliance.aspx#feedback</comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/8909.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Tip of the day #13 (String Equality)</title>
            <link>http://blog.colinmackay.net/archive/2009/07/12/Tip-of-the-day-13-String-Comparison.aspx</link>
            <description>&lt;p&gt;When comparing two strings in a case insensitive manner, use:&lt;/p&gt;
&lt;pre&gt;myFirstString.Equals(mySecondString, StringComparison.InvariantCultureIgnoreCase)&lt;/pre&gt;
&lt;p&gt;or, if cultural rules are to be ignored completely* then use: &lt;/p&gt;
&lt;pre&gt;myFirstString.Equals(mySecondString, StringComparison.OrdinalIgnoreCase)&lt;/pre&gt;
&lt;p&gt;over: &lt;/p&gt;
&lt;pre&gt;myFirstString.ToLower() == mySecondString.ToLower()&lt;/pre&gt;
&lt;p&gt;&lt;small&gt;* The invariant culture is actually a non-region specific English language culture. The ordinal comparison is faster than any culture specific comparison as it uses a much simpler comparison algorithm.&lt;/small&gt;&lt;/p&gt;&lt;img src="http://blog.colinmackay.net/aggbug/8228.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2009/07/12/Tip-of-the-day-13-String-Comparison.aspx</guid>
            <pubDate>Sun, 12 Jul 2009 11:19:05 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/8228.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2009/07/12/Tip-of-the-day-13-String-Comparison.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/8228.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Tip of the Day #11 (iMicros)</title>
            <link>http://blog.colinmackay.net/archive/2009/07/08/Tip-of-the-Day-11-iMicros.aspx</link>
            <description>&lt;p&gt;&lt;a href="https://addons.mozilla.org/en-US/firefox/addon/3863"&gt;iMicros&lt;/a&gt; is a plug in for &lt;a href="http://www.mozilla-europe.org/en/firefox/"&gt;FireFox&lt;/a&gt; that lets you automate repetitive tasks. This is a fantastic tool for anyone that develops websites as the flow through the site can be recorded and played back quickly and repeatedly. It reduces tester error by taking the mundane parts out of performing user tests. It can also deal with AJAX, has a stopwatch so you can time page loads, and many other things.&lt;/p&gt;&lt;img src="http://blog.colinmackay.net/aggbug/8113.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2009/07/08/Tip-of-the-Day-11-iMicros.aspx</guid>
            <pubDate>Wed, 08 Jul 2009 18:51:39 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/8113.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2009/07/08/Tip-of-the-Day-11-iMicros.aspx#feedback</comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/8113.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Tip of the day  #10 (XP Pro IIS Admin)</title>
            <link>http://blog.colinmackay.net/archive/2009/07/07/Tip-of-the-day--10-XP-Pro-IIS-Admin.aspx</link>
            <description>&lt;p&gt;If you are in the same situation as me where you have to develop web applications on Windows XP and have many projects on the go and for what ever reason cannot just stick each into its own virtual directory then &lt;a href="http://jetstat.com/iisadmin/ "&gt;XP Pro IIS Admin&lt;/a&gt; is the tool that you need.&lt;/p&gt;  &lt;p&gt;What it does is allow you to create multiple web sites in Windows XP (as it only permits one web site) and gives you a little interface for easily switching between them. This makes it much easier to work on multiple projects, especially when the projects expect to be sitting at the top of a website, rather than stuck away in some virtual directory somewhere.&lt;/p&gt;&lt;img src="http://blog.colinmackay.net/aggbug/8088.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2009/07/07/Tip-of-the-day--10-XP-Pro-IIS-Admin.aspx</guid>
            <pubDate>Tue, 07 Jul 2009 19:17:54 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/8088.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2009/07/07/Tip-of-the-day--10-XP-Pro-IIS-Admin.aspx#feedback</comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/8088.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Tip of the Day #9 (The Project Location Is Not Trusted)</title>
            <link>http://blog.colinmackay.net/archive/2009/03/23/Tip-of-the-Day-9-The-Project-Location-Is-Not.aspx</link>
            <description>&lt;p&gt;This tip is to get a tool called &lt;a href="http://www.jameskovacs.com/blog/PermaLink.aspx?guid=6985963b-3d85-41ae-bca8-5f9efe2a79c7"&gt;ZoneStripper&lt;/a&gt; by &lt;a href="http://www.jameskovacs.com/blog/default.aspx"&gt;James Kovaks&lt;/a&gt; to stop the annoying "project location not trusted" dialog box, below, appearing when you open downloaded solutions in Visual Studio.&lt;/p&gt;
&lt;p&gt;If you download zipped source code from the web, unzip it and then open the solution in Visual Studio 2008 (and apparently VS 2003 and VS 2005 as well) you may get a dialog that says "The project location is not trusted" ... "Running the application may result in security exceptions when it attempts to perform actions which require full trust." A bit like this:&lt;/p&gt;
&lt;p align="center"&gt;&lt;a title="Snagit Capture for Flickr" href="http://www.flickr.com/photos/colinangusmackay/3379975731"&gt;&lt;img height="323" alt="The project location is not trusted" width="500" src="http://farm4.static.flickr.com/3432/3379975731_fbd677e60b.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;What happens is that when you download something from the internet Windows (from Windows XP SP2 onwards) will add an alternate stream to the file called zone.identifier. If the file is a zip it will then add that alternate stream to each of the files as it unzips.&lt;/p&gt;
&lt;p&gt;You can view this stream by typing something like the following at a command prompt:&lt;/p&gt;
&lt;pre&gt;notepad DevWeek2009_PreCon.zip:zone.identifier&lt;/pre&gt;
&lt;p&gt;You can then read the contents of the alternate stream:&lt;/p&gt;
&lt;p align="center"&gt;&lt;a title="Snagit Capture for Flickr" href="http://www.flickr.com/photos/colinangusmackay/3380003693"&gt;&lt;img height="117" alt="" width="500" src="http://farm4.static.flickr.com/3563/3380003693_2fa2a037c0.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;What the ZoneStripper program does is delete the zone.identifier alternate stream from the file so that zone aware applications (and the OS) treat the file normally.&lt;/p&gt;
&lt;p&gt;Note: If you unzip the files to a FAT based file system then you won't have a zone.identifier in the first place as the FAT file system does not support alternate file streams.&lt;/p&gt;&lt;img src="http://blog.colinmackay.net/aggbug/6985.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2009/03/23/Tip-of-the-Day-9-The-Project-Location-Is-Not.aspx</guid>
            <pubDate>Mon, 23 Mar 2009 23:52:10 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/6985.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2009/03/23/Tip-of-the-Day-9-The-Project-Location-Is-Not.aspx#feedback</comments>
            <slash:comments>6</slash:comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/6985.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Tip of the Day #8 (string performance)</title>
            <link>http://blog.colinmackay.net/archive/2008/08/04/3221.aspx</link>
            <description>&lt;p&gt;Concatenating strings in .NET can be very easy. There is the overloaded + operator that makes &lt;strong&gt;stringA + stringB + stringC&lt;/strong&gt; statements very easy to write. But, it isn't very performant. The reason is that strings are immutable, and concatenating strings in this way causes lots of short-lived objects to be created and thrown away, which in turn causes the garbage collector to run frequently.&lt;/p&gt;  &lt;p&gt;There are two better ways in .NET to concatenate strings. One is to use the &lt;strong&gt;string.Concat()&lt;/strong&gt; method. The other is to use the &lt;strong&gt;StringBuilder&lt;/strong&gt; class. They both perform better than adding strings together, but you still have to know when to use each. &lt;/p&gt;  &lt;p&gt;According to this article on "&lt;a href="http://www.codeproject.com/KB/cs/stringperf.aspx" target="_blank"&gt;Performance considerations for strings in C#&lt;/a&gt;" &lt;strong&gt;string.Concat()&lt;/strong&gt; is good up to 600 strings. But, only if you have 600 strings to concatenate in a single statement. &lt;strong&gt;StringBuilder&lt;/strong&gt; is better if you have more than 600 strings to concatenate, but you can do so over multiple statements. In reality, I think the benefits of appending strings over multiple statements with &lt;strong&gt;StringBuilder&lt;/strong&gt; will work out better even with much less than 600 strings because to get the performance out of &lt;strong&gt;string.Concat()&lt;/strong&gt; you'll have to perform some form of setup operation to line all those strings up - and that will take time.&lt;/p&gt;  &lt;p&gt;So, today's tip is don't use the plus operator to combine strings except in quick / throw-away applications. Use &lt;strong&gt;string.Concat()&lt;/strong&gt; or &lt;strong&gt;StringBuilder&lt;/strong&gt; instead.&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:f0529d1c-f618-4773-828b-706583c2de62" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/string" rel="tag"&gt;string&lt;/a&gt;,&lt;a href="http://technorati.com/tags/concatenation" rel="tag"&gt;concatenation&lt;/a&gt;,&lt;a href="http://technorati.com/tags/concat" rel="tag"&gt;concat&lt;/a&gt;,&lt;a href="http://technorati.com/tags/stringbuilder" rel="tag"&gt;stringbuilder&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blog.colinmackay.net/aggbug/3221.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2008/08/04/3221.aspx</guid>
            <pubDate>Mon, 04 Aug 2008 12:00:54 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/3221.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2008/08/04/3221.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/3221.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Tip of the Day #7 (SysInternals)</title>
            <link>http://blog.colinmackay.net/archive/2008/07/30/3140.aspx</link>
            <description>&lt;p&gt;I've visited the &lt;a target="_blank" href="http://technet.microsoft.com/en-us/sysinternals/default.aspx"&gt;&lt;strong&gt;SysInternals&lt;/strong&gt;&lt;/a&gt; site a few times over the course of my career because of some strange problem that I just couldn't track down. The amount of information about what is actually happening on your system that the &lt;a target="_blank" href="http://technet.microsoft.com/en-us/sysinternals/default.aspx"&gt;&lt;strong&gt;SysInternals&lt;/strong&gt;&lt;/a&gt; tools provide is phenomenal. The site was run by &lt;a href="http://blogs.technet.com/markrussinovich/about.aspx"&gt;Mark Russinovich&lt;/a&gt; and Bryce Cogswell until they got hired by Microsoft. However, the tools are still available and being updated, only now they are hosted by Microsoft themselves.&lt;/p&gt;
&lt;p&gt;So, today's tip is to visit the &lt;a target="_blank" href="http://technet.microsoft.com/en-us/sysinternals/default.aspx"&gt;&lt;strong&gt;SysInternals&lt;/strong&gt;&lt;/a&gt; page on &lt;a target="_blank" href="http://www.microsoft.com/en/gb/default.aspx"&gt;Microsoft&lt;/a&gt;'s &lt;a target="_blank" href="http://technet.microsoft.com/en-gb/default.aspx"&gt;TechNet&lt;/a&gt; site and familiarise yourself with what is available. You might find that one day it will save you hours of frustration.&lt;/p&gt;&lt;img src="http://blog.colinmackay.net/aggbug/3140.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2008/07/30/3140.aspx</guid>
            <pubDate>Wed, 30 Jul 2008 14:47:33 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/3140.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2008/07/30/3140.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/3140.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>