<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1118477949704984682</id><updated>2024-08-31T04:40:52.585-07:00</updated><category term=".net"/><category term="KnowDotNet"/><category term="javascript"/><category term="ASP.NET"/><category term="mvc"/><category term="jQuery"/><category term="ruby"/><category term="sql"/><category term="Reporting Services"/><category term="access"/><category term="cheat_sheets"/><category term="css"/><category term="exception"/><category term="eyeD3"/><category term="git"/><category term="helpers"/><category term="html"/><category term="python"/><category term="software"/><category term="tips"/><category term="video"/><category term="visual_studio"/><title type='text'>Justin Wishart</title><subtitle type='html'>Programming weblog...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>29</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-1543795152991801638</id><published>2011-05-17T23:52:00.000-07:00</published><updated>2011-05-17T23:52:47.852-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="css"/><category scheme="http://www.blogger.com/atom/ns#" term="html"/><title type='text'>Css Resets</title><content type='html'>I&#39;ve come across Eric&#39;s Reset, but not the Yahoo and MaxDesign ones, so thought it was about time to make a list when I did: (I&#39;ll add as I find them)&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/&quot;&gt;meyerweb.com | Reset Reloaded&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://developer.yahoo.com/yui/reset/&quot;&gt;Yahoo! YUI Reset &lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.maxdesign.com.au/articles/css-reset/&quot;&gt;maxdesign | Css Reset - a simpler option&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://html5doctor.com/html-5-reset-stylesheet/&quot;&gt;Html 5 Doctor | Html 5 Reset&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/1543795152991801638/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/05/css-resets.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/1543795152991801638'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/1543795152991801638'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/05/css-resets.html' title='Css Resets'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-8993135156838286221</id><published>2011-04-26T22:49:00.000-07:00</published><updated>2011-04-26T22:49:43.523-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><title type='text'>Javascript Hash Libraries</title><content type='html'>Today I came across these hash algorithm implementations in Javascript.&lt;br /&gt;
&lt;br /&gt;
SHA-256 :&amp;nbsp;&lt;a href=&quot;http://anmar.eu.org/projects/jssha2/&quot;&gt;http://anmar.eu.org/projects/jssha2/&lt;/a&gt;&amp;nbsp;(&lt;a href=&quot;http://anmar.eu.org/projects/jssha2/files/jssha2-0.3.zip&quot;&gt;download&lt;/a&gt;)&lt;br /&gt;
MD5 &amp;amp; SHA1:&amp;nbsp;&lt;a href=&quot;http://pajhome.org.uk/crypt/md5/&quot;&gt;http://pajhome.org.uk/crypt/md5/&lt;/a&gt;&amp;nbsp;(&lt;a href=&quot;http://pajhome.org.uk/crypt/md5/jshash-2.2.zip&quot;&gt;download&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
The download links are to the latest versions as of 2011-04-27.</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/8993135156838286221/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/04/javascript-hash-libraries.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/8993135156838286221'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/8993135156838286221'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/04/javascript-hash-libraries.html' title='Javascript Hash Libraries'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-7992758777574781929</id><published>2011-04-25T19:34:00.000-07:00</published><updated>2011-04-25T19:38:07.795-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".net"/><category scheme="http://www.blogger.com/atom/ns#" term="exception"/><category scheme="http://www.blogger.com/atom/ns#" term="sql"/><title type='text'>OleDbException | Exception on Inserting a Date</title><content type='html'>The exception in question is an OleDbException with the message: &quot;The fractional part of the provided time value overflows the scale of the corresponding SQL Server parameter or column. Increase bScale in DBPARAMBINDINFO or column scale to correct this error.&quot;&lt;br /&gt;
&lt;br /&gt;
I was&amp;nbsp;receiving&amp;nbsp;this error when inserting a row that contained a DateTime in Sql Server.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Firstly, Some Context&lt;/span&gt;&lt;br /&gt;
The context is that I have an application that I&#39;m volunteering some time on that has OleDbConnections/OleDbCommands scattered through many pages. It used to connect to a Microsoft Access database, but I moved it to Sql Server and ended up using a connection string that uses the&amp;nbsp;SQLNCLI10 provider (Originally the SQLNCLI provider, but that wasn&#39;t provided on the host that we signed up for) I didn&#39;t want to change all the&amp;nbsp;occurrences&amp;nbsp;of OleDbConnection etc obviously.&lt;br /&gt;
&lt;br /&gt;
I&amp;nbsp;received&amp;nbsp;the above mentioned exception and had a quick look, but didn&#39;t find anything obvious as to why this might be happening. The exception is somewhat clear, but why this was happening in my case was not so clear.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;The Test Code&lt;/span&gt;&lt;br /&gt;
I made a simple test application that talked to a database to simply insert a date. The code that fails is thus:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;string query = &quot;INSERT INTO DateTimeTest ([Date]) VALUES (?)&quot;;

var date = DateTime.Now;

OleDbConnection connection = new OleDbConnection(
    connectionString );

OleDbCommand command = new OleDbCommand( query, connection );
command.Parameters.Add(new OleDbParameter( &quot;Date&quot;, date));

connection.Open();

command.ExecuteNonQuery();
&lt;/pre&gt;&lt;br /&gt;
Fairly simple stuff. Note that the connection string is stored in a variable called &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;connectionString&lt;/span&gt;&amp;nbsp;and looks something like this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;string connectionString = &quot;PROVIDER=SQLNCLI10;database=TESTING;Server=localhost\\instance_name; trusted_connection=yes&quot;;&lt;/pre&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;The Solution&lt;/span&gt;&lt;br /&gt;
The solution to my problem was to change the way that I was adding the date as a parameter to the command so that the command knew that it was a DateTime; like this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;command.Parameters.Add( &quot;Date&quot;, OleDbType.Date ).Value = date;
&lt;/pre&gt;&lt;br /&gt;
I now no longer get the exception and my code works. Yay! :oD&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Explanation&lt;/span&gt;&lt;br /&gt;
I&#39;m not sure exactly why the failing code failed, but I suspect that it might be something along the lines of that the provider doesn&#39;t know or try to determine the type that the OleDb type that the parameter should be and therefore might just call .ToString() on the date time and try and insert it in this manner, and thus the error. I&#39;ve not verified that this is what is happening though.</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/7992758777574781929/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/04/oledbexception-exception-on-inserting.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/7992758777574781929'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/7992758777574781929'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/04/oledbexception-exception-on-inserting.html' title='OleDbException | Exception on Inserting a Date'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-1970063477630440058</id><published>2011-04-22T21:15:00.000-07:00</published><updated>2011-04-25T19:39:34.058-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".net"/><title type='text'>Extension Methods | Calling Extension Methods on Null References</title><content type='html'>&quot;Can extension methods be called on a null reference?&quot; That was what I said when I read the following on a post by Marc Gravell&#39;s where he says:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;(the Step(…) method is implemented as an &lt;u&gt;extension method&lt;/u&gt;, &lt;u&gt;so it is perfectly happy operating on a null reference&lt;/u&gt;; which is a crude but simple way of short-circuiting the timings for regular users)&lt;/blockquote&gt;&lt;br /&gt;
To be honest I had never thought about this before... I therefore had to try it out and figure out why!&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;using System;

namespace ExtensionMethodNullReferenceTest
{
    class Program
    {
        static void Main( string [] args ) {
            ((object)null).SaySomething();
        }
    }

    static class ExtensionMethod
    {
        public static void SaySomething( this object obj ) {
            Console.WriteLine( &quot;Saying something...&quot; );
        }
    }
}
&lt;/pre&gt;&lt;br /&gt;
In the example above we have a very simple extension method called SaySomething(). In Main I&#39;m calling that extension method on... well... nothing.&lt;br /&gt;
&lt;br /&gt;
If we remind ourselves that extension methods are not really extending the object, but are simply static methods on a static class, and that they are called as static methods, this makes sense. The object that we appear to be calling the extension method on is just passed as an argument to the static extension method.&lt;br /&gt;
&lt;br /&gt;
The Il produced for the call to the extension method is as follows, the null reference being pushed onto the stack for the first parameter:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;call void ExtensionMethodNullReferenceTest.ExtensionMethod::SaySomething(object)&lt;/pre&gt;&lt;br /&gt;
This raises a possibly obvious issue. If we are going to do anything with the object that is passed we need to be careful. The following code will throw a NullReferenceException&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;using System;

namespace ExtensionMethodNullReferenceTest
{
    class Program
    {
        static void Main( string [] args ) {
            ((object)null).SaySomething();
        }
    }

    static class ExtensionMethod
    {
        public static void SaySomething( this object obj ) {
            Console.WriteLine( obj.ToString() );
        }

    }
}
&lt;/pre&gt;&lt;br /&gt;
The error is as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. at ExtensionMethodNullReferenceTest.Program.Main(String[] args) in C:\_Development\Examples\ExtensionMethodNullReferenceTest\ExtensionMethodNullReferenceTest\Program.cs:line 8&lt;/blockquote&gt;&lt;br /&gt;
Interestingly, in the error I received above, I don&#39;t actually get a line number inside the extension method. ( Though when I put another Console.WriteLine() above the first Console.WriteLine() in the extension method I do then get an exception message that tells me the line number within the extension method.)&lt;br /&gt;
&lt;br /&gt;
The main point is that if you are calling an extension method on an object reference that is null and you try and do something with that reference within the extension method, you could get an exception if not careful.</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/1970063477630440058/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/04/extension-methods-calling-extension.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/1970063477630440058'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/1970063477630440058'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/04/extension-methods-calling-extension.html' title='Extension Methods | Calling Extension Methods on Null References'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-4313887590813145181</id><published>2011-04-20T21:33:00.000-07:00</published><updated>2011-04-25T19:39:34.059-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".net"/><category scheme="http://www.blogger.com/atom/ns#" term="mvc"/><title type='text'>microsoft-web-helpers MVC3 | SimpleMembershipProvider Error</title><content type='html'>I tried to install the microsoft-web-helpers (version 1.1) package via NuGet today and then all of a sudden I could not build because I received an error saying that &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;SimpleMembershipProvider&lt;/span&gt;&amp;nbsp;could not be found.&lt;br /&gt;
&lt;br /&gt;
The solution is to add the following references to the project:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;WebMatrix.Data&lt;/li&gt;
&lt;li&gt;WebMatrix.WebData&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
I found the solution &lt;a href=&quot;http://stackoverflow.com/questions/4687438/asp-net-mvc-3-issues-with-microsoft-web-helpers-v1-1&quot;&gt;here&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/4313887590813145181/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/04/microsoft-web-helpers-mvc3.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/4313887590813145181'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/4313887590813145181'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/04/microsoft-web-helpers-mvc3.html' title='microsoft-web-helpers MVC3 | SimpleMembershipProvider Error'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-3024626614439265638</id><published>2011-03-23T16:48:00.000-07:00</published><updated>2011-04-25T19:39:34.061-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".net"/><title type='text'>Max Length of CultureInfo.Name Property</title><content type='html'>I was looking for the answer to the question: &quot;What is the maximum length of the CultureInfo.Name property?&quot; and came across &lt;a href=&quot;http://stackoverflow.com/questions/4862765/max-length-of-the-cultureinfo-name-property/&quot;&gt;this question&lt;/a&gt;. I&#39;ve answered the question but thought that I would find the answer easier if it was on my blog (ie. here).&lt;br /&gt;
&lt;br /&gt;
The reason that the maximum is 84 characters is because that is what the CultureAndRegionInfoBuilder class restricts the length to. But you can&#39;t just declare a culture called &quot;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: collapse; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 18px;&quot;&gt;ThisIsLongerThan8Characters&lt;/span&gt;&quot; because you must seperate the culture name with - (or _ it seems) with each part being a maximum of 8 characters long.&lt;br /&gt;
&lt;br /&gt;
The following code creates a culture with a length of 84 characters, registers it, uses it and unregisters it.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;string cultureName = &quot;qwertyui-12345678-qwertyui-12345678-qwertyui-12345678-qwertyui-12345678-qwertyui-123&quot;;
Console.WriteLine( &quot;MAX LENGTH: &quot; + cultureName.Length );
try {
    CultureAndRegionInfoBuilder.Unregister( cultureName );
} catch {
    Console.WriteLine( &quot;Cannot remove culture&quot; );
}

CultureAndRegionInfoBuilder builder = new CultureAndRegionInfoBuilder( cultureName , CultureAndRegionModifiers.None );
             
CultureInfo ci = new CultureInfo( &quot;en-AU&quot; );
RegionInfo ri = new RegionInfo( &quot;US&quot; );

builder.LoadDataFromCultureInfo( ci );
builder.LoadDataFromRegionInfo( ri );
builder.Register();

CultureInfo info = new CultureInfo( cultureName );
            
Console.WriteLine( DateTime.Now.ToString( info.DateTimeFormat.LongDatePattern ) );
Console.WriteLine( info.Name );
Console.WriteLine( info.DisplayName );

try {
    CultureAndRegionInfoBuilder.Unregister( cultureName );
} catch {
    Console.WriteLine( &quot;Cannot remove culture&quot; );
}
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/3024626614439265638/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/03/max-length-of-cultureinfoname-property.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/3024626614439265638'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/3024626614439265638'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/03/max-length-of-cultureinfoname-property.html' title='Max Length of CultureInfo.Name Property'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-4140897806442135716</id><published>2011-03-22T21:02:00.000-07:00</published><updated>2011-04-25T19:39:34.062-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="helpers"/><category scheme="http://www.blogger.com/atom/ns#" term="mvc"/><title type='text'>Gravatar Helpers | ASP.NET MVC</title><content type='html'>&lt;b style=&quot;color: red&quot;&gt;Update&lt;/b&gt;: 2011-04-26 Changed the methods from returning string to returning MvcHtmlString (silly me) and created a few more overloads to assign a title attribute.&lt;br /&gt;
&lt;br /&gt;
Was looking for a helper that I&#39;d seen previously. I still haven&#39;t found it, but noticed&amp;nbsp;&lt;a href=&quot;http://blog.wekeroad.com/2010/01/20/my-favorite-helpers-for-aspnet-mvc&quot;&gt;this&lt;/a&gt;&amp;nbsp;post with Gravatar helpers.&lt;br /&gt;
&lt;br /&gt;
I&#39;ve adjusted it in the following ways:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;The code didn&#39;t &lt;a href=&quot;http://en.gravatar.com/site/implement/hash/&quot;&gt;trim or lowercase&lt;/a&gt; the email address before hashing, so I changed that&lt;/li&gt;
&lt;li&gt;I added an overload which takes an enum for selecting the default image.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;The Url for the default image was not being &lt;a href=&quot;http://en.gravatar.com/site/implement/images/#default-image&quot;&gt;Url encoded&lt;/a&gt;. This is fine if you are using one of the defaults that they provide, but might not work if you pass a Url to an image in.&lt;/li&gt;
&lt;li&gt;There are several more overloads&lt;/li&gt;
&lt;li&gt;Generally made more of a mess :oD&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;Some of these changed just help to ensure that there are no problems when getting the Gravatar, some are just niceties for me which are probably a little clearer to read, but not really necessary considering that you would generally call these a total of maybe 1 or 2 places in an application.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Hope this is useful to someone.&lt;/div&gt;&lt;pre class=&quot;brush: c#&quot;&gt;using System;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Web.Mvc;

namespace Catechize.Helpers
{
    public enum GravatarDefault
    {
        FileNotFound,
        MysteryMan,
        Identicon,
        MonsterID,
        Wavatar,
        Retro
    }

    // Kudos to Rob Connery http://blog.wekeroad.com/2010/01/20/my-favorite-helpers-for-aspnet-mvc
    public static class GravatarHelpers
    {
        public static MvcHtmlString Gravatar(this HtmlHelper helper, string email)
        {
            var url = GetGravatarUrl(helper, CleanupEmail(email), 40, GetDefaultGravatarString(GravatarDefault.MysteryMan));
            return MvcHtmlString.Create(ConstructImgTag(url));
        }

        public static MvcHtmlString Gravatar(this HtmlHelper helper, string email, string title) {
            var url = GetGravatarUrl(helper, CleanupEmail(email), 40, GetDefaultGravatarString(GravatarDefault.MysteryMan));
            return MvcHtmlString.Create(ConstructImgTag(url, title));
        }

        public static MvcHtmlString Gravatar(this HtmlHelper helper, string email, int size)
        {
            var url = GetGravatarUrl(helper, CleanupEmail(email), size, GetDefaultGravatarString(GravatarDefault.MysteryMan));
            return MvcHtmlString.Create(ConstructImgTag(url));
        }

        public static MvcHtmlString Gravatar(this HtmlHelper helper, string email, string title, int size)
        {
            var url = GetGravatarUrl(helper, CleanupEmail(email), size, GetDefaultGravatarString(GravatarDefault.MysteryMan));
            return MvcHtmlString.Create(ConstructImgTag(url, title));
        }

        public static MvcHtmlString Gravatar(this HtmlHelper helper, string email, int size, string defaultImageUrl)
        {
            var url = GetGravatarUrl(helper, CleanupEmail(email), size, UrlEncode(helper, defaultImageUrl));
            return MvcHtmlString.Create(ConstructImgTag(url));
        }

        public static MvcHtmlString Gravatar(this HtmlHelper helper, string email, string title, int size, string defaultImageUrl)
        {
            var url = GetGravatarUrl(helper, CleanupEmail(email), size, UrlEncode(helper, defaultImageUrl));
            return MvcHtmlString.Create(ConstructImgTag(url, title));
        }

        public static MvcHtmlString Gravatar(this HtmlHelper helper, string email, int size, GravatarDefault defaultImage)
        {
            var mode = GetDefaultGravatarString(defaultImage);

            var url = GetGravatarUrl(helper, CleanupEmail(email), size, mode);
            return MvcHtmlString.Create(ConstructImgTag(url));
        }

        public static MvcHtmlString Gravatar(this HtmlHelper helper, string email, string title, int size, GravatarDefault defaultImage)
        {
            var mode = GetDefaultGravatarString(defaultImage);

            var url = GetGravatarUrl(helper, CleanupEmail(email), size, mode);
            return MvcHtmlString.Create(ConstructImgTag(url, title));
        }

        public static string GetDefaultGravatarString(GravatarDefault defaultGravatar) {
            var mode = String.Empty;
            switch (defaultGravatar)
            {
                case GravatarDefault.FileNotFound:
                    mode = &quot;404&quot;;
                    break;
                case GravatarDefault.Identicon:
                    mode = &quot;identicon&quot;;
                    break;
                case GravatarDefault.MysteryMan:
                    mode = &quot;mm&quot;;
                    break;
                case GravatarDefault.MonsterID:
                    mode = &quot;monsterid&quot;;
                    break;
                case GravatarDefault.Wavatar:
                    mode = &quot;wavatar&quot;;
                    break;
                case GravatarDefault.Retro:
                    mode = &quot;retro&quot;;
                    break;
                default:
                    mode = &quot;mm&quot;;
                    break;
            }
            return mode;
        }


        private static string ConstructImgTag(string src, string title = &quot;Gravatar&quot;)
        {
            var result = &quot;&lt;img src=\&quot;{0}\&quot; alt=\&quot;Gravatar\&quot; class=\&quot;gravatar\&quot; title=\&quot;{1}\&quot; /&gt;&quot;;
            return String.Format(result, src, title);
        }

        static string GetGravatarUrl(HtmlHelper helper, string email, int size, string defaultImage)
        {
            string result = &quot;http://www.gravatar.com/avatar/{0}?s={1}&amp;r=PG&quot;;
            string emailMD5 = EncryptMD5(CleanupEmail(email));

            result = (string.Format(result,
                        EncryptMD5(email), size.ToString()));

            if (false == String.IsNullOrEmpty(defaultImage))
                result += &quot;&amp;d=&quot; + defaultImage;
        
            return result;
        }

        private static string UrlEncode(HtmlHelper helper, string url)
        {
            var urlHelper = new UrlHelper(helper.ViewContext.RequestContext);
            return urlHelper.Encode(url);
        }

        private static string CleanupEmail(string email)
        {
            email = email.Trim();
            email = email.ToLower();

            return email;
        }

        private static string EncryptMD5(string value)
        {
            byte[] bytes;

            using (var md5 = MD5.Create())
            {
                bytes = Encoding.ASCII.GetBytes(value);
                bytes = md5.ComputeHash(bytes);
            }

            return String.Concat(bytes.Select(t =&gt; t.ToString(&quot;x2&quot;)));
        }
    }
}
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/4140897806442135716/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/03/gravatar-helpers-aspnet-mvc.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/4140897806442135716'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/4140897806442135716'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/03/gravatar-helpers-aspnet-mvc.html' title='Gravatar Helpers | ASP.NET MVC'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-7974798279895554299</id><published>2011-03-16T23:29:00.000-07:00</published><updated>2011-04-25T19:39:34.063-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="jQuery"/><title type='text'>jQuery.validate &amp;ndash; Setting default ignore rules</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;&lt;strong style=&quot;color: red;&quot;&gt;Note:&lt;/strong&gt; This post is from my old blog (2010-03-10)&lt;/div&gt;&lt;br /&gt;
I’ve been &lt;a href=&quot;http://stackoverflow.com/questions/2414551/jquery-validator-cannot-assign-default-ignore-selector-to-jquery-validator-defaul&quot; target=&quot;_blank&quot;&gt;trying&lt;/a&gt; to setup jQuery.validate so that it ignores hidden elements on the form. By hidden I mean that the element is not visible; not that it is an input of type hidden.&lt;br /&gt;
&lt;br /&gt;
The definition of defaults.ignore is an array…&lt;br /&gt;
&lt;pre class=&quot;brush: javascript&quot;&gt;ignore: []&lt;/pre&gt;… so I pushed my “:hidden” string into the array… but that didn’t work.&lt;br /&gt;
This setting is eventually passed to the jQuery &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;.not()&lt;/span&gt; function like this:&lt;br /&gt;
&lt;pre class=&quot;brush: javascript&quot;&gt;.not( this.settings.ignore )&lt;/pre&gt;So by assigning a string to the defaults like this:&lt;br /&gt;
&lt;pre class=&quot;brush: javascript&quot;&gt;jQuery.validator.defaults.ignore = &quot;:hidden&quot;;&lt;/pre&gt;The string “:hidden” will be passed to the jQuery &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;.not()&lt;/span&gt; function when selecting valid form elements and the elements that are non visible (match the selector “:hidden”) will be ignored during validation…</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/7974798279895554299/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/03/jqueryvalidate-setting-default-ignore.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/7974798279895554299'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/7974798279895554299'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/03/jqueryvalidate-setting-default-ignore.html' title='jQuery.validate &amp;ndash; Setting default ignore rules'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-3210341911313694209</id><published>2011-03-16T23:08:00.000-07:00</published><updated>2011-04-25T19:39:34.064-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="jQuery"/><category scheme="http://www.blogger.com/atom/ns#" term="mvc"/><title type='text'>Custom Server and Client Side Required Validator in MVC 2 using jQuery.validate</title><content type='html'>&lt;div style=&quot;text-align: center&quot;&gt;&lt;strong style=&quot;color: red&quot;&gt;Note:&lt;/strong&gt; This post was originally posted on my old blog on 2010-03-22&lt;/div&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;strong&gt;Update:&lt;/strong&gt; Added information on issues that I’ve still yet to solve.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;strong&gt;Update:&lt;/strong&gt; Added information about replacing the custom validator provider to apply a custom error message when a numeric field is not a number (custom validator provider applies validation which is in english, and i wanted to get the values from my custom resource file which is globalized.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
My goals were as follows:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Custom Required validation on the Client and Server side; validation using DataAnnotations (A custom one)&lt;/li&gt;
&lt;li&gt;Localized message (The validation message just says “Required” in the given user’s language.)&lt;/li&gt;
&lt;li&gt;Wanted the DataAnnotation attribute to be called JRequire and not require anything passed to the attribute (The normal RequiredAttribute allows you to assign the type of a resource file and the key and therefore localize validation messages. I want to avoid having to repeatedly assign these values: to make the code cleaner and make it quicker to apply)&lt;/li&gt;
&lt;li&gt;Wanted to use jQuery.Validate for client side validation.&lt;/li&gt;
&lt;/ul&gt;Phil Haack has a good article &lt;a href=&quot;http://haacked.com/archive/2009/11/19/aspnetmvc2-custom-validation.aspx&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt; on custom validation. It covers most of what i needed for this so I wont explain a lot of the following.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Contents:&lt;/h3&gt;&lt;ol&gt;&lt;li&gt;Custom Validation Attribute&lt;/li&gt;
&lt;li&gt;Custom Data Annotations Model Validator&lt;/li&gt;
&lt;li&gt;Registering Validation on the server side&lt;/li&gt;
&lt;li&gt;Registering Validation on the Client side&lt;/li&gt;
&lt;li&gt;Implicit Required Attribute Problem (DateTimes and ints are required for example!)&lt;/li&gt;
&lt;li&gt;Implicit Non-Numeric-Field problem&lt;/li&gt;
&lt;/ol&gt;&lt;h3&gt;Custom Validation Attribute&lt;/h3&gt;&lt;pre class=&quot;brush: c#&quot;&gt;[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple=false)]
public class JRequiredAttribute : ValidationAttribute
{
    public JRequiredAttribute()
    {
        ErrorMessageResourceName = &quot;Required&quot;;
        ErrorMessageResourceType = typeof(ValidationMessages);
    }

    public override bool IsValid(object value)
    {
        if (value == null)
            return false;

        string str = value as string;

        if (String.IsNullOrEmpty(str))
            return false;

        return true;
    }
}&lt;/pre&gt;In the constructor I’m specifying the key in the resource file that contains the message. The second line is the type containing the resources. If I have a resource file for a given culture other than english and the user’s culture is set to that culture then the message will be shown in that culture instead of in english.&lt;br /&gt;
&lt;br /&gt;
Note that I’ve set &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;globalization uiCulture=&quot;auto&quot; culture=&quot;auto&quot;/&amp;gt;&lt;/span&gt; in the configuration file.&lt;br /&gt;
&lt;br /&gt;
The IsValid method is overridden and i return true if there is content and false if there is not. Fairly simple.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Custom Data Annotations Model Validator&lt;/h3&gt;&lt;pre class=&quot;brush: c#&quot;&gt;public class JRequiredValidator : DataAnnotationsModelValidator
{
    public JRequiredValidator(
        ModelMetadata metadata,
        ControllerContext context,
        JRequiredAttribute attribute)
        : base(metadata, context, attribute)
    {
    }

    public override IEnumerable
    GetClientValidationRules()
    {
        var rule = new ModelClientValidationRule {
            ErrorMessage = ValidationMessages.Required,
            ValidationType = &quot;jrequired&quot;
        };

        return new [] {rule};
    }
}&lt;/pre&gt;This piece of code is is used to generate the client side JSON that is written to the page. The client side validation framework can then hook into this information to do the client side validation. Now for registration:&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Registering Validation on the server side&lt;/h3&gt;This involved modifying the Global.asax.cs file. After registering the routes do the following:&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;DataAnnotationsModelValidatorProvider.RegisterAdapter(
    typeof(JRequiredAttribute),
    typeof(JRequiredValidator));&lt;/pre&gt;&lt;br /&gt;
&lt;h3&gt;Registering Validation on the Client side&lt;/h3&gt;I’ll assume that you have the following JavaScript files registered on the page:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;jQuery 1.4.*.js&lt;/li&gt;
&lt;li&gt;jquery.validate.js&lt;/li&gt;
&lt;li&gt;The MicrosoftMvcJQueryValidation.js file which can be downloaded from &lt;a href=&quot;http://aspnet.codeplex.com/releases/view/41742&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt; (Download “ASP.NET MVC 2 Futures” and in explorer expand MvcFutures and you will see the javascript file there)&lt;/li&gt;
&lt;/ul&gt;Once this is done you only have one more things to do and that is to extend jQuery.validate to use your new custom required attribute by adding a custom method:&lt;br /&gt;
&lt;pre class=&quot;brush: javascript&quot;&gt;jQuery.validator.addMethod(&quot;jrequired&quot;, function(value, element) {
    if (value == undefined || value == null)
        return false;

    if (value.toString().length == 0)
        return false;

    return true;
});&lt;/pre&gt;The above can be added to the top of the MicrosoftMvcJQueryValidation.js file (where is says “register custom jQuery methods”&lt;br /&gt;
&lt;br /&gt;
Note the first parameter&amp;nbsp; to the addMethod.. er… method. This is the same as the ValidationType property set when we defined the JRequiredValidator class. The function takes the value and checks that it is not null (or undefined) and checks that if it has a length of 0 characters that we also return false; otherwise we know that the field has an appropriate value and we can return true. True meaning that the field is valid, false meaning it is not.&lt;br /&gt;
&lt;br /&gt;
The above code is rough as we don’t check to see if there are any valid characters (for example a string of length 1 where the character is a space should not be valid in this case. The server side String.IsNullOrEmpty does do this check, but the client code doesn’t. As this was just to get things going i will update the above when I refine it (if i remember).&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Implicit Required Attribute Problem&lt;/h3&gt;The above will work well on text fields (where your model has a string property), but when you try and apply this sort of logic onto DateTime properties etc. We have an issue because the framework automatically applies the required attribute to them :p not fair! :)&lt;br /&gt;
&lt;br /&gt;
A solution to this is to make the property nullable and let the validation handle enforcing whether the property is valid… not very nice though.&lt;br /&gt;
&lt;br /&gt;
I found another method which is to set the DataAnnotationsModelValidatorProvider’s AddImplicitRequiredAttributeForValueTypes to false (by default it’s true obviously!)&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;&lt;/pre&gt;&lt;h3&gt;Implicit Non-Numeric-Field problem&lt;/h3&gt;The MVC framework automatically applies a couple of Model Validator Providers&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;DataAnnotationsModelValidatorProvider&lt;/li&gt;
&lt;li&gt;DataErrorInfoModelValidatorProvider&lt;/li&gt;
&lt;li&gt;ClientDataTypeModelValidatorProvider&lt;/li&gt;
&lt;/ul&gt;I have no idea what the first two are, but i needed to replace the 3rd one’s error message, and it seems the only way to do that is to replace the whole ClientDataTypeModelValidatorProvider with a custom one that references the correct error message, remove the registered provider and register my own. So I created a file called CustomClientTypeModelValidatorProvider which containes the same code as the ClientDataTypeModelValidatorProvider class in the MVC framework with a change to the internal NumericModelValidator classes MakeErrorString() method. It is by default this:&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;private static string MakeErrorString(string displayName) {
    // use CurrentCulture since this message is intended for the site visitor
    return String.Format(CultureInfo.CurrentCulture,
        MvcResources.ClientDataTypeModelValidatorProvider_FieldMustBeNumeric,
        displayName);
}&lt;/pre&gt;And is now this:&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;private static string MakeErrorString(string displayName) {
    // use CurrentCulture since this message is intended for the site visitor
    return String.Format(CultureInfo.CurrentCulture,
        ValidationMessages.FieldMustBeNumeric);
}&lt;/pre&gt;... referencing my custom resource file.&lt;br /&gt;
&lt;br /&gt;
Now to unregister the old and register the new&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;// Remove the item that validates fields are numeric!
foreach (ModelValidatorProvider prov in ModelValidatorProviders.Providers) {
    if (prov.GetType().Equals(typeof(ClientDataTypeModelValidatorProvider))) {
        ModelValidatorProviders.Providers.Remove(prov);
        break;
    }
}

// Add our own of the above with a custom message!
ModelValidatorProviders.Providers.Add(
    new CustomClientDataTypeModelValidatorProvider());&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/3210341911313694209/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/03/custom-server-and-client-side-required.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/3210341911313694209'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/3210341911313694209'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/03/custom-server-and-client-side-required.html' title='Custom Server and Client Side Required Validator in MVC 2 using jQuery.validate'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-5285605828165604375</id><published>2011-03-14T20:46:00.000-07:00</published><updated>2011-04-25T19:39:34.066-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".net"/><category scheme="http://www.blogger.com/atom/ns#" term="KnowDotNet"/><title type='text'>KnowDotNet: String.Intern() and String.IsInterned()</title><content type='html'>Interning is a process where the compiler creates a pool of string references to literal strings in an application. You can use this feature to prevent re-allocation of the same string in memory. An interned string will stay in memory until the CLR has shutdown so this may be something to consider if memory usage is an issue/priority.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;using System;
using System.Text;

namespace String_Intern_Test
{
    class Program
    {
        static void Main( string [] args ) {
            // Compile Time Interning
            var myInternedString = &quot;This string is interned at compile time&quot;;
            Console.WriteLine( String.IsInterned( myInternedString ) 
                == null ? &quot;NO&quot; : &quot;YES&quot; ); // shows YES

            // Runtime Interning
            // IMPORTANT: Don&#39;t use StringBuilder to concatenate strings like this
            // I&#39;ve used StringBuilder to avoid creating a string literal which would
            // be automatically interned.
            StringBuilder myStringBuilder = new StringBuilder();
            myStringBuilder.Append( &quot;This is going to be&quot; );
            myStringBuilder.Append( &quot; interned soon!&quot; );

            var myString = myStringBuilder.ToString();

            Console.WriteLine( String.IsInterned( myString ) 
                == null ? &quot;NO&quot;: &quot;YES&quot; );  // shows NO
            String.Intern( myString );
            Console.WriteLine( String.IsInterned( myString ) 
                == null ? &quot;NO&quot; : &quot;YES&quot; );  // shows YES

        }
    }
}

&lt;/pre&gt;&lt;br /&gt;
In line 10 we create a string. The actual value of the string, ie. &quot;This string is interned at compile time&quot;, is assigned for interning at compile time. The Console.WriteLine() will return YES meaning that the string was interned. Note a few things about line 11, 24 and 27: The strings are cast to objects so that the == operator tests equality of the references whereas strings redefine the behaviour of the == operator to do a comparison of the CONTENTS of the two strings.&lt;br /&gt;
&lt;br /&gt;
From line 15 we have the start of a test where we programmatically intern a string. We use &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;StringBuilder &lt;/span&gt;to construct a string to avoid the creation of a literal (or something that the compiler can figure out will be one whole string literal) &lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;myString &lt;/span&gt;is eventually created from the &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;StringBuilder &lt;/span&gt;contents... but note that this string is NOT interned (thus on line 24 you get a result of &quot;NO&quot;. We then intern using &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;String.Intern()&lt;/span&gt; and test again, this time we get YES on line 28.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;String.Intern()&lt;/span&gt; will return the string if it is interned, if it doesn&#39;t exist it will intern the string and return the new interned string reference.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;String.IsInterned()&lt;/span&gt; will return the string reference if it is interned, or&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt; null &lt;/span&gt;if it is not interned.&lt;br /&gt;
&lt;br /&gt;
Now, when you have two string literals the compiler will intern the string and anywhere else you use that same string literal will refer, at runtime, to the same reference (or both strings will reference the same object.) To show this here is the above with a few alterations.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;using System;
using System.Text;

namespace String_Intern_Test
{
    class Program
    {
        static void Main( string [] args ) {
            // Compile Time Interning
            var myInternedString = &quot;This string is interned at compile time&quot;;
            Console.WriteLine( String.IsInterned( myInternedString )
                == null ? &quot;NO&quot; : &quot;YES&quot; );

            Test( myInternedString );
        }

        static void Test(string otherString) {
            var myInternedString2 = &quot;This string is interned at compile time&quot;;

            Console.WriteLine((object) otherString 
                == (object) myInternedString2);
        }
    }
}
&lt;/pre&gt;In this example line 20 will return True. &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;otherString &lt;/span&gt;is actually the &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;myInternedString &lt;/span&gt; string from the &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;main()&amp;nbsp;&lt;/span&gt;method. &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;myInternedString &lt;/span&gt;is interned at compile time, and &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;myInternedString2 &lt;/span&gt;will reference the same string in memory due to interning. Inside the &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Test()&lt;/span&gt; method we are comparing the references of these two strings and, as they are both exactly the same string literals, the compiler will intern the string and anywhere that string exists in the code will be loaded from the pool of strings. In other words anywhere the string literal exists will result in the same string reference being used.</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/5285605828165604375/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/03/knowdotnet-stringintern-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/5285605828165604375'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/5285605828165604375'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/03/knowdotnet-stringintern-and.html' title='KnowDotNet: String.Intern() and String.IsInterned()'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-88440938244884197</id><published>2011-03-14T19:48:00.000-07:00</published><updated>2011-04-25T19:39:34.067-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".net"/><category scheme="http://www.blogger.com/atom/ns#" term="KnowDotNet"/><title type='text'>KnowDotNet: String.Insert()</title><content type='html'>Another function I don&#39;t think I&#39;ve ever used before... I tend to use String.Format() to insert values into strings or just concatenate them so I&#39;m not sure how much I&#39;ll use this.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;using System;

namespace String_Insert
{
    class Program
    {
        static void Main( string [] args ) {
            string interesting = &quot;This is interesting&quot;;

            var veryInteresting = interesting.Insert( 8, &quot;very &quot; );

            Console.WriteLine( interesting );
            Console.WriteLine( veryInteresting );
        }
    }
}
&lt;/pre&gt;&lt;br /&gt;
We start off in line 8 creating a string and then in line 10 we insert the word &quot;very &quot; into that string using the &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Insert()&lt;/span&gt; method of the &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;interesting &lt;/span&gt;object. This returns a new string with the words &quot;This is very interesting&quot;.</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/88440938244884197/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/03/knowdotnet-stringinsert.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/88440938244884197'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/88440938244884197'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/03/knowdotnet-stringinsert.html' title='KnowDotNet: String.Insert()'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-4974749913278584733</id><published>2011-03-14T18:32:00.000-07:00</published><updated>2011-03-14T18:32:00.511-07:00</updated><title type='text'>Send Secure Email Via Gmail in Ruby 1.8.7</title><content type='html'>&lt;div id=&quot;_mcePaste&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red; font-family: Cantarell; font-size: 15px; line-height: 20px;&quot;&gt;&lt;b&gt;Note&lt;/b&gt;:&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;This post was originally posted on my old blog on 8th of June 2010&lt;/span&gt;&lt;/div&gt;I&#39;m working on a small web app in my spare time in which I need to send out emails with attachments in Ruby on Rails... First step is to actually send an email... I wanted to do this using my Gmail account so that any responses that might come back would be into my everyday email account. I also wanted it to use SSL/TLS... This whole thing was a bit difficult to figure out especially with the smtp_tls.rb examples on the net. I got a bit confused...&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: blue;&quot;&gt;For Ruby 1.8.6 (and maybe older) see &lt;a href=&quot;http://seattlerb.rubyforge.org/smtp_tls/&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;This is the code that I have come up with for Ruby 1.8.7 in the end...&lt;/div&gt;&lt;pre class=&quot;brush: ruby&quot;&gt;require &#39;net/smtp&#39;

smtp = Net::SMTP.new &#39;smtp.gmail.com&#39;, 587
smtp.enable_starttls

message = &amp;lt;&amp;lt;EMAIL_MESSAGE
From: John Smith &amp;lt;example_from@gmail.com&amp;gt;
To: Joe Smith &amp;lt;example_to@gmail.com&amp;gt;
Subject: Just a little test...
This is test...
EMAIL_MESSAGE

smtp.start(&#39;smtp.gmail.com&#39;,
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;gmail_username_here&#39;,&#39;password_here&#39;, :plain ) do |smpt|
&amp;nbsp;&amp;nbsp; &amp;nbsp;smtp.send_message message,
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&#39;example_from@gmail.com&#39;,
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&#39;example_to@gmail.com&#39;
end&lt;/pre&gt;Some notes:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;In Ruby 1.8.7 you don&#39;t have to install the smtp_tls gem like you did in prior versions as this is included in the net/smtp.rb file already. you just have to set&amp;nbsp;&lt;span style=&quot;font-family: Consolas, Monaco, &#39;Courier New&#39;, Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt;smtp.enable_starttls&lt;/span&gt; before you call start(..)&lt;/li&gt;
&lt;li&gt;You don&#39;t have to put the @gmail.com part on the end of you email in the gmail_username_here&amp;nbsp;place hold.&lt;/li&gt;
&lt;li&gt;The body of the message has to be constructed fully, you can&#39;t call functions to build it... There are a couple of other gems that you can use to make this a little nicer. Some things to look at include : &lt;a href=&quot;http://github.com/mikel/mail&quot; target=&quot;_blank&quot;&gt;mail&lt;/a&gt;, &lt;a href=&quot;http://tmail.rubyforge.org/&quot; target=&quot;_blank&quot;&gt;TMail&lt;/a&gt; for example, which may make this a bit cleaner.&lt;/li&gt;
&lt;/ul&gt;The rest should be fairly straight forward. The next piece in the puzzle with be figuring out how to add attachments and then figuring out how to render a PDF in prawnto as an attachment, in rails; without saving it as a file first :)</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/4974749913278584733/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/03/send-secure-email-via-gmail-in-ruby-187.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/4974749913278584733'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/4974749913278584733'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/03/send-secure-email-via-gmail-in-ruby-187.html' title='Send Secure Email Via Gmail in Ruby 1.8.7'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-708285074906341585</id><published>2011-03-13T21:06:00.000-07:00</published><updated>2011-04-25T19:39:34.067-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".net"/><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><title type='text'>ASP.NET WebForms Server Control Notes</title><content type='html'>A few years ago now I was working on learning ASP.NET WebForms server control development. I put together, at the time, a document containing examples and clarification on aspects that I found confusing.&lt;br /&gt;
&lt;br /&gt;
You can download it &lt;a href=&quot;http://cid-6e2e1ee6eec57182.office.live.com/self.aspx/Public/Server%20Control%20Development%20Guide2.pdf&quot;&gt;here&lt;/a&gt;:&lt;br /&gt;
&lt;br /&gt;
It goes into the various Attributes that you use and I tried (to the best of my ability at the time) to write examples (in VB.NET) showing how they are used.&lt;br /&gt;
&lt;br /&gt;
Hope this is helpful to someone.</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/708285074906341585/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/03/aspnet-webforms-server-control-notes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/708285074906341585'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/708285074906341585'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/03/aspnet-webforms-server-control-notes.html' title='ASP.NET WebForms Server Control Notes'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-8988783676755659785</id><published>2011-03-13T20:51:00.000-07:00</published><updated>2011-04-25T19:39:34.068-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Reporting Services"/><title type='text'>Installing Sql Server 2005 Reporting Services on Vista and deal with issues</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;b&gt;Note&lt;/b&gt;: &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;This post was originally posted on my old blog on 25th of June 2009&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;Update: &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;em&gt;(2009-06-26)&lt;/em&gt;&lt;/span&gt; - Added the Windows x64 server issue.&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;Update:&lt;span style=&quot;color: grey;&quot;&gt;&lt;em&gt; (2009-10-26)&lt;/em&gt;&lt;/span&gt;&lt;/span&gt; - Added quick note about running IE as administrator in all cases and noted that the notes work with Windows 7&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;Update:&lt;span style=&quot;color: grey;&quot;&gt;&lt;em&gt; (2009-11-10)&lt;/em&gt;&lt;/span&gt;&lt;/span&gt; – Link to MSDN article on Configuring Report Server for Local Admin on Vista and added another step to the Trusted Sites instructions. Also added a note that I installed Reporting Services to run as Local System.&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;Update:&lt;span style=&quot;color: grey;&quot;&gt;&lt;em&gt; (2009-11-11)&lt;/em&gt;&lt;/span&gt;&lt;/span&gt; – Added a link and some information from a post on a forum which talked about using Management Studio to assign permissions to the report server (Even though I wasn’t able to connect to the Report Server using Management Studio to try it out… :( Groan, Complain!&lt;br /&gt;
&lt;br /&gt;
The introduction of Windows Vista to the world caused some compatibility issues with a variety of software. One of those is an actual Microsoft product.&lt;br /&gt;
&lt;br /&gt;
Sql Server 2005 Reporting Services has been an absolute pain to get running. I&#39;ve nearly spent the whole day trying to get it working so that I can get to the Report Manager and manage the reports.&lt;br /&gt;
&lt;br /&gt;
In this article I&#39;m installing Sql Server 2005 With Advanced Services With SP3 on a Vista Business Box. and will also try and describe some of the errors that you may get and how to fix them.&lt;br /&gt;
&lt;h1&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: x-large;&quot;&gt;Prerequisites:&lt;/span&gt;&lt;/h1&gt;Please note the following:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;You have to install Sql Server 2005 on a Vista Business, Vista Enterprise or Vista Ultimate box. You cannot use Vista Basic or Vista Premium.&lt;/li&gt;
&lt;li&gt;You cannot install Sql Server 2005 Enterprise Edition on Vista Machines.&lt;/li&gt;
&lt;/ul&gt;You need to ensure that several features are installed in Windows as follows:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Go to the Control Panel.&lt;/li&gt;
&lt;li&gt;Double click &quot;Programs and Features&quot;&lt;/li&gt;
&lt;li&gt;Click &quot;Turn Windows features on or off&quot;&lt;/li&gt;
&lt;li&gt;Click &quot;Continue&quot; on the UAC dialog&lt;/li&gt;
&lt;/ol&gt;You now need to select the correct features which are listed below:&lt;br /&gt;
&lt;br /&gt;
Under &lt;strong&gt;Internet Information Services | Web Management Tools| IIS 6 Management Compatibility&lt;/strong&gt; select:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;IIS 6 WMI Compatibility&lt;/li&gt;
&lt;li&gt;IIS Metabase and IIS 6 configuration compatibility&lt;/li&gt;
&lt;/ul&gt;Under &lt;strong&gt;Internet Information Services | &lt;/strong&gt;&lt;strong&gt;World Wide Web Services | Application Development Features&lt;/strong&gt; select:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;ASP.NET&lt;/li&gt;
&lt;li&gt;ISAPI Extensions&lt;/li&gt;
&lt;li&gt;ISAPI Filters&lt;/li&gt;
&lt;/ul&gt;Under&amp;nbsp; &lt;strong&gt;Internet Information Services &lt;/strong&gt;&lt;strong&gt;| &lt;/strong&gt;&lt;strong&gt;World Wide Web Services &lt;/strong&gt;&lt;strong&gt;| &lt;/strong&gt;&lt;strong&gt;Common Http Features&lt;/strong&gt; Select:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Default Document&lt;/li&gt;
&lt;li&gt;Directory Browsing&lt;/li&gt;
&lt;li&gt;HTTP Errors&lt;/li&gt;
&lt;li&gt;HTTP Redirection&lt;/li&gt;
&lt;li&gt;Static Content&lt;/li&gt;
&lt;/ul&gt;Under&amp;nbsp; &lt;strong&gt;Internet Information Services &lt;/strong&gt;&lt;strong&gt;| &lt;/strong&gt;&lt;strong&gt;World Wide Web Services &lt;/strong&gt;&lt;strong&gt;| Security&lt;/strong&gt; Select:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Windows Authentication&lt;/li&gt;
&lt;/ul&gt;&lt;h1&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: x-large;&quot;&gt;Installation&lt;/span&gt;&lt;/h1&gt;Follow the &lt;a href=&quot;http://support.microsoft.com/default.aspx/kb/934164/en-us&quot; target=&quot;_blank&quot;&gt;Microsoft instructions&lt;/a&gt; to install Sql Server 2005 (Some of the above information is also included in the instructions provided by Microsoft)&lt;br /&gt;
&lt;br /&gt;
When you get to the &lt;strong&gt;Report Server Installation Options&lt;/strong&gt; dialog select &lt;strong&gt;Install the default configuration&lt;/strong&gt; so that you dont have to configure things manually.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;strong style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Note:&lt;/span&gt;&lt;/strong&gt; &lt;span style=&quot;color: #004080;&quot;&gt;In my setup of Reporting Services I have it running as Local System. You might want to select this for Reporting Services unless you know better :)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h1&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: x-large;&quot;&gt;Post Installation Changes&lt;/span&gt;&lt;/h1&gt;&lt;h2&gt;Ensuring Read, Script and Execute for ReportServer&lt;/h2&gt;&lt;ol&gt;&lt;li&gt;Open IIS Manager. Open a command prompt and type &quot;inetmgr&quot;&lt;/li&gt;
&lt;li&gt;Drill down to the website and click on the &quot;ReportServer&quot; virtual directory (remember that if you have a named instance it will be called &quot;ReportServer$&lt;em&gt;namedinstance&lt;/em&gt;&quot;&lt;/li&gt;
&lt;li&gt;Under the server components category at the bottom, double click &quot;Handler Mappings&quot;&lt;/li&gt;
&lt;li&gt;In the &quot;Actions&quot; sidebar click &quot;Edit Feature Permissions...&quot;&lt;/li&gt;
&lt;li&gt;Ensure that &quot;Read&quot;, &quot;Script&quot; and &quot;Execute&quot; are all checked!&lt;/li&gt;
&lt;li&gt;You might want to restart the application pool or website after this&lt;/li&gt;
&lt;/ol&gt;&lt;h2&gt;Turn off SSL Requirement&lt;/h2&gt;This is only really for development purposes. In a production environment you might setup SSL. I don&#39;t want it!&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;On the start menu select &lt;strong&gt;All Programs | Micosoft Sql Server 2005 | Configuration Tools | Reporting Services Configuration&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Enter the machine name and instance name and connect&lt;/li&gt;
&lt;li&gt;Click on the &quot;Report Server Virtual Directory&quot; Item to the left and ensure that the &quot;Require Secure Socket Layer (SSL) connections&quot; is unchecked (unless you want it, which in out case we don&#39;t.)&lt;/li&gt;
&lt;/ol&gt;&lt;h2&gt;Set IE Trusted Sites to Include http://localhost (and http://&lt;em&gt;machinename&lt;/em&gt;)&lt;/h2&gt;This one is actually in the Microsoft instructions for installing Sql Server 2005. Here it is for convenience, as it&#39;s a small thing, but can cause frustration :)&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Open IE&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Internet Options &lt;/strong&gt;on the &lt;strong&gt;Tools &lt;/strong&gt;menu&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Security&lt;/strong&gt; tab.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Trusted Sites&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Sites&lt;/strong&gt; button&lt;/li&gt;
&lt;li&gt;Add http://localhost and http://&lt;em&gt;machinename&lt;/em&gt; to the list of trusted sites.&lt;/li&gt;
&lt;li&gt;Clear the “Require server certification (https:) for all sites in this zone” if not using https.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Close&lt;/strong&gt; and &lt;strong&gt;OK&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;For some reason IE will only show the top section of the home folder without all of the required functionality that you need. This fixes that problem.&lt;br /&gt;
&lt;br /&gt;
For fuller instructions on the above as well as configuring the site security settings, see &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb630430.aspx&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;h1&gt;&lt;strong&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-large;&quot;&gt;Errors&lt;/span&gt;&lt;/strong&gt;&lt;/h1&gt;This section details some of the errors that I&#39;ve had at variouse times and attempts to give some guidance on how to fix them!&lt;strong&gt;&lt;br /&gt;
&lt;/strong&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span style=&quot;color: red;&quot;&gt;I can see the home page but can&#39;t do anything&lt;/span&gt;&lt;/h2&gt;See the &quot;Set IE Trusted Sites to Include http://localhost (and http:/&lt;em&gt;machinename&lt;/em&gt;)&quot; section above.&lt;br /&gt;
&lt;br /&gt;
It is important that you run IE as administrator also. Once you can see the root folder and the buttons to add folders you can go to the Properties tab and give the appropriate accounts permission to access the folder and any sub folders.&lt;br /&gt;
&lt;br /&gt;
IF you can see the home page but no content (where you have already applied the other fixes) then you can also give yourself permissions using Sql Server Management Studio: at least in some cases. I can’t do that, but someone else I know was able to get around this issue using the method below.&lt;br /&gt;
&lt;br /&gt;
(Below, for convenience, is from &lt;a href=&quot;http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/034b42bc-0b09-421a-84db-ad49783fa893#6eafad04-c084-4ed7-ac0a-e5e1e479fbff&quot;&gt;this entry&lt;/a&gt; on social.msdn.microsoft.com)&lt;br /&gt;
&lt;blockquote&gt;The solution that worked for me was:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Run Sql Server Management Studio as Administrator (right click &quot;Run as Administrator&quot;)&lt;/li&gt;
&lt;li&gt;Connect to a Reporting Services server using Windows Authentication.&lt;/li&gt;
&lt;li&gt;Right click Home, Select Properties, Select Permissions.&lt;/li&gt;
&lt;li&gt;Click Add Group or User, Type your Username, Click Ok.&lt;/li&gt;
&lt;li&gt;Check the box for Content Manager, Click Ok.&lt;/li&gt;
&lt;/ol&gt;Now you can access Reporting Services via Sql Server Management Console without running as administrator.&lt;br /&gt;
&lt;br /&gt;
You should also have permissions to browse Report Manager (http://localhost/Reports).&amp;nbsp; If not, but you do see the Information Bar complaining then add http://localhost/ to Explorer&#39;s Trusted Sites Zone.&lt;/blockquote&gt;&lt;h2&gt;&lt;span style=&quot;color: red;&quot;&gt;Access is denied: You do not have permission to view this directory or page using the credentials you supplied...&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;padding-left: 30px;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;Access is denied.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;h1 style=&quot;padding-left: 30px;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;Server Error in &#39;/Reports$JJJ&#39; Application.&lt;/span&gt;&lt;br /&gt;
&lt;hr size=&quot;1&quot; /&gt;&lt;/h1&gt;&lt;h2 style=&quot;padding-left: 30px;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;em&gt;Access is denied.&lt;/em&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;padding-left: 30px;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span style=&quot;font-family: arial, helvetica, geneva, sunsans-regular, sans-serif;&quot;&gt;&lt;strong&gt;Description: &lt;/strong&gt;An error occurred while accessing the resources required to serve this request. You might not have permission to view the requested resources.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding-left: 30px;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;strong&gt;Error message 401.3: &lt;/strong&gt;You do not have permission to view this directory or page using the credentials you supplied (access denied due to Access Control Lists). Ask the Web server&#39;s administrator to give you access to &#39;c:\Program Files\Microsoft SQL Server\MSSQL.16\Reporting Services\ReportManager\Pages\Folder.aspx&#39;.&lt;/span&gt;&lt;/div&gt;&lt;hr size=&quot;1&quot; /&gt;&lt;div style=&quot;padding-left: 30px;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;strong&gt;Version Information:&lt;/strong&gt; Microsoft .NET Framework Version:2.0.50727.4016; ASP.NET Version:2.0.50727.4016&lt;/span&gt;&lt;/div&gt;This is an ASP.NET Error. It means that the account I used (which was my normal domain user account) was being impersonated by the web application, but that account doesn&#39;t have rights to the given folder.&lt;br /&gt;
&lt;br /&gt;
Solution:&lt;br /&gt;
&lt;br /&gt;
Give your account &quot;FULL&quot; rights to the folder. It seems not to work with anything less!&lt;br /&gt;
&lt;h2&gt;&lt;span style=&quot;color: red;&quot;&gt;Reporting Services Error: The request failed with HTTP status 403: Forbidden&lt;/span&gt;&lt;/h2&gt;With this error you get an IIS error. Please ensure that you have done what is specified in the the &lt;strong&gt;Post Installation Changes &lt;/strong&gt;section above&lt;br /&gt;
&lt;h2&gt;&lt;span style=&quot;color: red;&quot;&gt;IE Error with dialog box asking for credentials&lt;/span&gt;&lt;/h2&gt;You get the following error after entering your credentials into a dialog box (3 times)&lt;br /&gt;
&lt;h2 style=&quot;padding-left: 30px;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;HTTP Error 401.3 - Unauthorized&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;padding-left: 30px;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;You do not have permission to view this directory or page because of the access control list (ACL) configuration or encryption settings for this resource on the Web server.&lt;/span&gt;&lt;/h3&gt;The box asking for credentials must be on that can access&amp;nbsp; the report manager application folder which for the example I&#39;m currently doing is &quot;&lt;span style=&quot;font-family: arial, helvetica, geneva, sunsans-regular, sans-serif;&quot;&gt;c:\Program Files\Microsoft SQL Server\MSSQL.16\Reporting Services\ReportManager\&quot;. If the account doens&#39;t have the permissions&lt;/span&gt; it will ask another two times and then give you the above error.&lt;br /&gt;
&lt;br /&gt;
You need to got to the directory and add the account you entered so that they have permissions to the directory specified on the error page. If you run as administrator you will probably not get this error, if you use another account you may get it. If you want to add that user then either give them rights to the directory or add them in a group that does have full rights to the given directory.&lt;br /&gt;
&lt;br /&gt;
When you have given the permissions you will get to the home page of the report manager. You have to run as administrator account and then setup the home folder permissions as well as configure site wide security so that the account has system administrator rights.&lt;br /&gt;
&lt;h2&gt;&lt;span style=&quot;color: red;&quot;&gt;Error: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.&lt;/span&gt;&lt;/h2&gt;This has been caused by the ReportServer virtual directory/application not having Read, Script and Execute features set.&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Open IIS Manager. Open a command prompt and type &quot;inetmgr&quot;&lt;/li&gt;
&lt;li&gt;Drill down to the website and click on the &quot;ReportServer&quot; virtual directory (remember that if you have a named instance it will be called &quot;ReportServer$&lt;em&gt;namedinstance&lt;/em&gt;&quot;&lt;/li&gt;
&lt;li&gt;Under the server components category at the bottom, double click &quot;Handler Mappings&quot;&lt;/li&gt;
&lt;li&gt;In the &quot;Actions&quot; sidebar click &quot;Edit Feature Permissions...&quot;&lt;/li&gt;
&lt;li&gt;Ensure that &quot;Read&quot;, &quot;Script&quot; and &quot;Execute&quot; are all checked!&lt;/li&gt;
&lt;li&gt;You might want to restart the application pool or website after this&lt;/li&gt;
&lt;/ol&gt;Check the &lt;strong&gt;Reports &lt;/strong&gt;virtual directory/application also.&lt;br /&gt;
&lt;h2&gt;&lt;span style=&quot;color: red;&quot;&gt;Windows Server 2003 R2 x64 issue&lt;/span&gt;&lt;/h2&gt;If you still get the home page of the Report Manager with no content on Windows Server 2003 R2 x64. You can solve it by adding the http://localhost to the Local Intranet Trusted List as shown &lt;a href=&quot;http://bladeoz.wordpress.com/2009/06/26/reporting-services-user-permissions/&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;&lt;br /&gt;
&lt;h2&gt;&lt;span style=&quot;color: red;&quot;&gt;Windows 7 Error – An Unexpected error occured on a recieve – Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;color: #008040; font-family: cou;&quot;&gt;The underlying connection was closed: An unexpected error occurred on a receive.&lt;br /&gt;
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.&lt;br /&gt;
An existing connection was forcibly closed by the remote host&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Have not been able to resolve this at the current moment.</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/8988783676755659785/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/03/installing-sql-server-2005-reporting.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/8988783676755659785'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/8988783676755659785'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/03/installing-sql-server-2005-reporting.html' title='Installing Sql Server 2005 Reporting Services on Vista and deal with issues'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-6483205010320467774</id><published>2011-03-11T00:28:00.000-08:00</published><updated>2011-04-25T19:39:34.069-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><title type='text'>Javascript: Changing what this means inside a function</title><content type='html'>&lt;b&gt;Note&lt;/b&gt;: This is a slightly re-worked post from a few years ago that I put on my old blog.&lt;br /&gt;
&lt;b&gt;Update 2011-03-12&lt;/b&gt;: Very helpful page generally, helpful section&amp;nbsp;&lt;a href=&quot;http://goo.gl/6GsUM&quot;&gt;Javascript Garden: How this works&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
I was wondering one day how you could change what &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;this &lt;/span&gt;refers to as sometimes you don&#39;t want it to refer to the current function, but to some other function (or object or whatever you want to call it.)&lt;br /&gt;
&lt;br /&gt;
Here is a little example: (&lt;a href=&quot;http://jsfiddle.net/AePf5/&quot;&gt;here&#39;s a link to it on jsFiddle&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: javascript&quot;&gt;function container() { 
    this.stuff = &quot;This is the value of container.stuff&quot;; 
    this.otherStuff = { 
        stuff: &quot;This is the value of container.otherstuff.stuff&quot; 
    };

    function alertThis() { 
        alert(this.stuff); 
    }

    alertThis();
 
    alertThis.call(otherStuff);
}

container();
&lt;/pre&gt;&lt;br /&gt;
So we define a variable on the container function called &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;stuff &lt;/span&gt;and assign the string &quot;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;This is the value of container.stuff&lt;/span&gt;&quot; to it... Fairly simple there!&lt;br /&gt;
&lt;br /&gt;
Then we assing a new object to another variable on the container function. the variable is called &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;otherStuff&lt;/span&gt;. The new object also has a variable called &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;stuff &lt;/span&gt;which is assigned the string &quot;otherStuff&quot;.&lt;br /&gt;
&lt;br /&gt;
The &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;alertThis()&lt;/span&gt; function is then defined. It gets the&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;stuff&amp;nbsp;&lt;/span&gt;variable from the &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;this&lt;/span&gt; object.&lt;br /&gt;
&lt;br /&gt;
Now we have two calls to &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;alertThis()&lt;/span&gt;. The first one simply calls the function. So inside &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;alertThis()&lt;/span&gt; the &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;this &lt;/span&gt;variable refers to the &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;container &lt;/span&gt;function. In other words &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;this.stuff&lt;/span&gt; is the same as calling &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;container.stuff&lt;/span&gt;, which returns &quot;stuff&quot;.&lt;br /&gt;
&lt;br /&gt;
The second call to &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;alertThis()&lt;/span&gt; is done by calling the &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;call()&lt;/span&gt;&amp;nbsp;method on the &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;alertThis()&lt;/span&gt; function and passing in a value. The &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;otherStuff&lt;/span&gt; argument (what is passed to &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;call()&lt;/span&gt;) becomes the value of &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;this &lt;/span&gt;inside the called function. So &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;this.stuff&lt;/span&gt; is the same as calling &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;otherStuff.stuff&lt;/span&gt; which returns the string &quot;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 15px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;This is the value of container.otherstuff.stuff&lt;/span&gt;&lt;/span&gt;&quot;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Clear as mud?</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/6483205010320467774/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/03/javascript-changing-what-this-means.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/6483205010320467774'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/6483205010320467774'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/03/javascript-changing-what-this-means.html' title='Javascript: Changing what this means inside a function'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-7230666968077208582</id><published>2011-03-10T23:45:00.000-08:00</published><updated>2011-04-25T19:39:34.070-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="git"/><title type='text'>Git Setup</title><content type='html'>I keep forgetting how to setup git configuration settings on new machines, especially the colours.  (&lt;a href=&quot;http://git.or.cz/course/svn.html&quot;&gt;Source&lt;/a&gt;)&lt;br /&gt;
&lt;pre&gt;git config --global user.name &quot;Your Name Comes Here&quot;
git config --global user.email you@yourdomain.example.com
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
&lt;/pre&gt;I keep forgetting how to setup the colors.</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/7230666968077208582/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/03/git-setup.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/7230666968077208582'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/7230666968077208582'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/03/git-setup.html' title='Git Setup'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-2117809478028686338</id><published>2011-03-10T20:53:00.000-08:00</published><updated>2011-04-25T19:39:34.071-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="software"/><title type='text'>Software List</title><content type='html'>This post is going to be a list of links to software that I have installed no my systems by default. (because when I reinstall a system or get a new one I always keep coming across tools that I&#39;ve forgotten to (re)install)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Browsers&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.google.com/chrome&quot;&gt;Chrome&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.mozilla.com/en-US/firefox/&quot;&gt;Firefox&lt;/a&gt;&amp;nbsp;- Plugins: &lt;a href=&quot;http://getfirebug.com/&quot;&gt;Firebug&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Development&lt;/b&gt;&lt;br /&gt;
Visual Studio Express - &lt;a href=&quot;http://www.microsoft.com/express/Web/&quot;&gt;Web&lt;/a&gt; &amp;amp; &lt;a href=&quot;http://www.microsoft.com/express/Windows/&quot;&gt;C# &amp;amp; C++&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.microsoft.com/express/Database/InstallOptions.aspx&quot;&gt;Sql Server Express with Advanced Services&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.asp.net/webmatrix&quot;&gt;WebMatrix&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.ruby-lang.org/en/downloads/&quot;&gt;Ruby&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://rubyonrails.org/&quot;&gt;Rails&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.python.org/download/&quot;&gt;Python&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.vim.org/download.php#pc&quot;&gt;Vim&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://git-scm.com/&quot;&gt;Git&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.fiddler2.com/Fiddler2/version.asp&quot;&gt;Fiddler2&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;a href=&quot;http://www.go-mono.com/mono-downloads/download.html&quot;&gt;Mono&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;a href=&quot;http://monodevelop.com/Download&quot;&gt;MonoDevelop&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;Tools&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;http://keepass.info/&quot;&gt;KeePass&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.apple.com/au/itunes/download/&quot;&gt;iTunes&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://www.evernote.com/&quot;&gt;Evernote&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.tweetdeck.com/&quot;&gt;TweetDeck&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://explore.live.com/windows-live-writer&quot;&gt;Windows Live Writer&lt;/a&gt; (blogging client which I&#39;m not using so much after switch to Blogger)&lt;br /&gt;
&lt;a href=&quot;http://notepad-plus-plus.org/&quot;&gt;Notepad++&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://audacity.sourceforge.net/&quot;&gt;Audacity&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.getpaint.net/index.html&quot;&gt;Paint.Net&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.gimp.org/&quot;&gt;Gimp&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://www.dropbox.com/install&quot;&gt;DropBox&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.google.com/talk/&quot;&gt;Google Talk&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.skype.com/intl/en/get-skype/&quot;&gt;Skype&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://picasa.google.com/&quot;&gt;Picasa&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.virtualbox.org/&quot;&gt;Virtual Box&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://filezilla-project.org/&quot;&gt;FileZilla&lt;/a&gt; (Client and Server (Server is Windows only))</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/2117809478028686338/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/03/software-list.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/2117809478028686338'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/2117809478028686338'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/03/software-list.html' title='Software List'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-4701005194991971780</id><published>2011-03-09T19:37:00.000-08:00</published><updated>2011-04-25T19:39:34.071-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".net"/><category scheme="http://www.blogger.com/atom/ns#" term="KnowDotNet"/><title type='text'>KnowDotNet: String.Concat() and string contatenation</title><content type='html'>String.Concat() allows you to pass in multiple strings and it will create a new string big enough to contain the individual strings that you pass into the function. It then copies the individual strings into the new bigger strings.&lt;br /&gt;
&lt;br /&gt;
So if you go like this:&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;using System;

class Tests
{
    static void Main( string [] args ) {
        string str1 = &quot;This is a number: &quot;;
        string str2 = 55.ToString();

        string newString = String.Concat( str1, str2 );
        Console.WriteLine( newString );
    }
}
&lt;/pre&gt;You will get:&lt;br /&gt;
&lt;pre&gt;This is a number: 55&lt;/pre&gt;If you change the line that declares the &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;newString&lt;/span&gt; variable to this:&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;string newString = str1 + str2;&lt;/pre&gt;The the IL code that is generated is exactly the same. String concatenation like that above is replaced by the compiler as a call to String.Concat(). In other words, the first example is fine; it just requires more typing. For more information on some of the interesting aspects of string concatenation then read &lt;a href=&quot;http://www.yoda.arachsys.com/csharp/stringbuilder.html&quot;&gt;this article&lt;/a&gt; called &quot;Concatenating Strings Efficiently&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;String.Concat() for Arrays of Strings.&lt;/span&gt;&lt;br /&gt;
Other String.Concat() overloads allows passing a string array as an argument. You can even pass arrays of objects; each on will have .ToString() called and the results concatenated.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;using System;

class Tests
{
    static void Main( string [] args ) {
        string [] items = { &quot;String1&quot;, &quot;String2&quot;, &quot;String3&quot; };

        string newString = String.Concat( items );
        Console.WriteLine( newString );
    }
}&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/4701005194991971780/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/03/knowdotnet-stringconcat-and-string.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/4701005194991971780'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/4701005194991971780'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/03/knowdotnet-stringconcat-and-string.html' title='KnowDotNet: String.Concat() and string contatenation'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-2925029254772537950</id><published>2011-03-08T13:57:00.000-08:00</published><updated>2011-07-19T13:25:24.300-07:00</updated><title type='text'>Libraries List</title><content type='html'>This post contains links to libraries that I use frequently, find useful, or just think I might use in the future. Needless to say that this is a work in progress.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-large;&quot;&gt;CDN&#39;s&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;a href=&quot;http://code.google.com/apis/libraries/&quot;&gt;Google&lt;/a&gt;&amp;nbsp;- jQuery, jQuery.ui &amp;amp; Others&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;a href=&quot;http://www.asp.net/ajaxlibrary/cdn.ashx&quot;&gt;Microsoft&lt;/a&gt;&amp;nbsp;-jQuery, jQuery.ui, jQuery.validate, jQuery.unobtrusive-ajax, jQuery.validate.unobtrusive,&amp;nbsp;MicrosoftMvcAjax (MVC 1.0 &amp;amp; 2.0)&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-large;&quot;&gt;Libraries&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;JavaScript&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;a href=&quot;http://jquery.com/&quot;&gt;jQuery&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;a href=&quot;http://jqueryui.com/&quot;&gt;jQuery.ui&lt;/a&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;a href=&quot;http://fgelinas.com/code/timepicker/&quot;&gt;jQuery.timepicker&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;a href=&quot;http://bassistance.de/jquery-plugins/jquery-plugin-validation/&quot;&gt;jQuery.validate&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://knockoutjs.com/&quot;&gt;knockoutjs&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://code.google.com/p/crypto-js/&quot;&gt;crypto-js&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://leandrovieira.com/projects/jquery/lightbox/&quot;&gt;lightbox&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://documentcloud.github.com/backbone/&quot;&gt;backbone.js&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://letteringjs.com/&quot;&gt;letteringjs&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://arborjs.org/&quot;&gt;arbor.js&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.jscharts.com/&quot;&gt;jschart&lt;/a&gt; - javascript chart library. Free for non-commercial use&lt;br /&gt;
&lt;a href=&quot;http://craigsworks.com/projects/qtip2/&quot;&gt;jTip2&lt;/a&gt; - tooltip jQuery plugin&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Script/resource loaders&lt;/b&gt;&lt;br /&gt;
(&lt;a href=&quot;https://spreadsheets.google.com/lv?key=tDdcrv9wNQRCNCRCflWxhYQ&amp;amp;f=true&amp;amp;gid=0&quot;&gt;This document&lt;/a&gt; contains a comparison of Javascript loader features)&lt;br /&gt;
&lt;a href=&quot;http://yepnopejs.com/&quot;&gt;yepnope.js&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;.NET&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;a href=&quot;http://pdfsharp.net/&quot;&gt;PdfSharp&lt;/a&gt;&amp;nbsp;-&amp;nbsp;Library&amp;nbsp;for generation of PDF&#39;s&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;a href=&quot;https://bitbucket.org/swaj/actionmailer.net/wiki/Home&quot;&gt;ActiveMailer.Net&lt;/a&gt;&amp;nbsp;(&lt;a href=&quot;http://geeksharp.com/2011/02/11/intro-to-actionmailer-net-screencast/&quot;&gt;Video Intro&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Online... Things&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.google.com/webfonts&quot;&gt;Google Webfonts&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://mediaplayer.yahoo.com/&quot;&gt;Yahoo! Media Player&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/2925029254772537950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/03/libraries-list.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/2925029254772537950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/2925029254772537950'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/03/libraries-list.html' title='Libraries List'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-6373586290108413320</id><published>2011-03-07T04:02:00.000-08:00</published><updated>2011-04-25T19:39:34.073-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".net"/><category scheme="http://www.blogger.com/atom/ns#" term="KnowDotNet"/><title type='text'>KnowDotNet: Index</title><content type='html'>I&#39;m making this post as the master index of functions etc. that I put into the KnowDotNet series of posts. (so it could get long if I can keep this up) I&#39;ll break things up into classes (alphabetical with links to the functions underneath) Though if I try and find information on things I&#39;ll probably just use the search.&lt;br /&gt;
&lt;br /&gt;
The tag for all of these posts is &lt;a href=&quot;http://jwwishart.blogspot.com/search/label/KnowDotNet&quot;&gt;KnowDotNet&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://jwwishart.blogspot.com/2011/03/knowdotnet-introduction.html&quot;&gt;Introduction&lt;/a&gt;&amp;nbsp;- This links to the post that describes why I&#39;m doing this...&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;String Class&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;http://jwwishart.blogspot.com/2011/03/knowdotnet-stringconcat-and-string.html&quot;&gt;String.Concat()&lt;/a&gt;&amp;nbsp;| &lt;a href=&quot;http://jwwishart.blogspot.com/2011/03/knowdotnet-stringinsert.html&quot;&gt;Insert()&lt;/a&gt;&amp;nbsp;| &lt;a href=&quot;http://jwwishart.blogspot.com/2011/03/knowdotnet-stringintern-and.html&quot;&gt;String.Intern() &amp;amp; String.IsInterned()&lt;/a&gt; |&amp;nbsp;&lt;a href=&quot;http://jwwishart.blogspot.com/2011/03/knowdotnet-stringisnullorempty.html&quot;&gt;String.IsNullOrEmpty()&lt;/a&gt;&amp;nbsp;|&amp;nbsp;&amp;nbsp;&lt;a href=&quot;http://jwwishart.blogspot.com/2011/03/knowdotnet-stringisnullorwhitespace.html&quot;&gt;String.IsNullOrWhiteSpace()&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/6373586290108413320/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/03/knowdotnet-index.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/6373586290108413320'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/6373586290108413320'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/03/knowdotnet-index.html' title='KnowDotNet: Index'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-6324736049477781006</id><published>2011-03-04T22:25:00.000-08:00</published><updated>2011-04-25T19:39:34.074-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><title type='text'>Quick and Dirty Sha1 Hash Creation</title><content type='html'>I had the need to hash a password to get a Sha1 Hash. I&#39;ve got ruby on my system so I thought I should be able to do that with Ruby. Quick search, found this and did &lt;a href=&quot;http://snippets.dzone.com/posts/show/83&quot;&gt;this snippet&lt;/a&gt;...&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;require &#39;digest/sha1&#39;
sha1 = Digest::SHA1.hexdigest(&#39;passwordHerePlease&#39;)
&lt;/pre&gt;Easier than opening Visual Studio, creating a project, inserting this in some function, importing the namespace System.Security.Cryptography, compiling, and running... :)&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;SHA1CryptoServiceProvider cryptoTransformSHA1 = 
    new SHA1CryptoServiceProvider();
string hash = BitConverter.ToString(
    cryptoTransformSHA1.ComputeHash(buffer)).Replace(&quot;-&quot;, &quot;&quot;);&lt;/pre&gt;&lt;br /&gt;
P.S. I was wondering how to turn the bytes into a Sha1 like what Ruby outputs. The code above for C# was from &lt;a href=&quot;http://dotnetpulse.blogspot.com/2007/12/sha1-hash-calculation-in-c.html&quot;&gt;here &lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/6324736049477781006/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/03/quick-and-dirty-sha1-hash-creation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/6324736049477781006'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/6324736049477781006'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/03/quick-and-dirty-sha1-hash-creation.html' title='Quick and Dirty Sha1 Hash Creation'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-2530315040534121751</id><published>2011-03-04T14:28:00.000-08:00</published><updated>2011-04-25T19:39:34.076-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".net"/><category scheme="http://www.blogger.com/atom/ns#" term="KnowDotNet"/><title type='text'>KnowDotNet: String.IsNullOrEmpty</title><content type='html'>Do you ever find yourself in a situation where you need to know whether a string is Null or empty. The following gist shows some code that tests this.&lt;br /&gt;
&lt;br /&gt;
(if you can&#39;t see the gist please click &lt;a href=&quot;https://gist.github.com/855810&quot;&gt;here&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/855810.js?file=Program.cs&quot;&gt;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
The output of this code is as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;Is Null: True
Is Null: False
Is Null: False
Is Empty: False
Is Empty: True
Is Empty: True
IsNullOrEmpty: True
IsNullOrEmpty: True
IsNullOrEmpty: True&lt;/pre&gt;&lt;br /&gt;
You will see that test1 is null and therefore not considered empty test2 and test3 have String.Empty or &quot;&quot; assigned and are both considered empty, but not null. In some scenario&#39;s you may not know necessarily what result from a function or somewhere else and you have to test for null AND equality to an empty string (or a string of Length == 0) Note: String.Empty is equal to &quot;&quot;&lt;br /&gt;
&lt;br /&gt;
This function conveniently does both tests for you</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/2530315040534121751/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/03/knowdotnet-stringisnullorempty.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/2530315040534121751'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/2530315040534121751'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/03/knowdotnet-stringisnullorempty.html' title='KnowDotNet: String.IsNullOrEmpty'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-7895744803536802026</id><published>2011-03-04T14:08:00.000-08:00</published><updated>2011-04-25T19:39:34.077-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="tips"/><category scheme="http://www.blogger.com/atom/ns#" term="video"/><category scheme="http://www.blogger.com/atom/ns#" term="visual_studio"/><title type='text'>2 Visual Studio Selection Tips</title><content type='html'>The below video shows two quick selection tips for Visual Studio. I&#39;m using 2010 version of Express edition for this video, though I&#39;m fairly sure it was in VS 2008 also.&lt;br /&gt;
&lt;br /&gt;
The video shows:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;How to select whole lines&lt;/li&gt;
&lt;li&gt;How to block select areas for typing, copying and pasting etc.&lt;/li&gt;
&lt;/ol&gt;&lt;div&gt;Hope it&#39;s helpful.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;object height=&quot;344&quot; width=&quot;600&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/KyPhp7xLFiY?hl=en&amp;fs=1&quot;&gt;&lt;/param&gt;&lt;param name=&quot;allowFullScreen&quot; value=&quot;true&quot;&gt;&lt;/param&gt;&lt;param name=&quot;allowscriptaccess&quot; value=&quot;always&quot;&gt;&lt;/param&gt;&lt;embed src=&quot;http://www.youtube.com/v/KyPhp7xLFiY?hl=en&amp;fs=1&quot; type=&quot;application/x-shockwave-flash&quot; allowscriptaccess=&quot;always&quot; allowfullscreen=&quot;true&quot; width=&quot;600&quot; height=&quot;344&quot;&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/7895744803536802026/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/03/2-visual-studio-selection-tips.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/7895744803536802026'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/7895744803536802026'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/03/2-visual-studio-selection-tips.html' title='2 Visual Studio Selection Tips'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-5545017538680978457</id><published>2011-03-04T03:24:00.000-08:00</published><updated>2011-04-25T19:39:34.078-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".net"/><category scheme="http://www.blogger.com/atom/ns#" term="KnowDotNet"/><title type='text'>KnowDotNet: String.IsNullOrWhiteSpace</title><content type='html'>So you don&#39;t care if a string has while space in it, all you want to do is ensure that a string doesn&#39;t have readable characters in it (or it&#39;s actually an empty string...&lt;br /&gt;
&lt;br /&gt;
A simple example:&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;string myString = &quot; &quot;;
String.IsNullOrWhiteSpace( myString );
&lt;/pre&gt;&lt;br /&gt;
In the above example this returns true, as &lt;code&gt;myString&lt;/code&gt; is not null and has only a space in it; no numbers or letters here!&lt;br /&gt;
&lt;br /&gt;
Note that the IsNullOrWhileSpace() method is a static method on the String class.&lt;br /&gt;
&lt;br /&gt;
Below is a gist containing several examples and their results. Next to the string variable declarations are comments showing what the code returns for the value of each string.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;namespace String_IsNullOrWhitespace_Test
{
    using System;

    class Program
    {
        static void Main( string [] args ) {
            string test1 = null;            // True
            string test2 = String.Empty;    // True
            string test3 = &quot;&quot;;              // True
            string test4 = &quot; &quot;;             // True
            string test5 = &quot;\t&quot;;            // True
            string test6 = &quot;\n&quot;;            // True
            string test7 = &quot; a&quot;;            // False
            string test8 = &quot;\0&quot;;            // False
            string test9 = &quot;\b&quot;;            // False
            string test10 = &quot;\a&quot;;           // False
           
            Console.WriteLine( String.IsNullOrWhiteSpace( test1 ) );
            Console.WriteLine( String.IsNullOrWhiteSpace( test2 ) );
            Console.WriteLine( String.IsNullOrWhiteSpace( test3 ) );
            Console.WriteLine( String.IsNullOrWhiteSpace( test4 ) );
            Console.WriteLine( String.IsNullOrWhiteSpace( test5 ) );
            Console.WriteLine( String.IsNullOrWhiteSpace( test6 ) );
            Console.WriteLine( String.IsNullOrWhiteSpace( test7 ) );
            Console.WriteLine( String.IsNullOrWhiteSpace( test8 ) );
            Console.WriteLine( String.IsNullOrWhiteSpace( test9 ) );
            Console.WriteLine( String.IsNullOrWhiteSpace( test10 ) );
        }
    }
}&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;Update: 2011-03-07&lt;/span&gt;&lt;/b&gt; - &lt;a href=&quot;http://twitter.com/tarnacious/&quot;&gt;Tarn Barford (@tarnacious)&lt;/a&gt; noted that this is a .Net 4 method. If you want similar functionality he mentioned that you can write an extension method... So for a bit more completeness here is one.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;using System;
using System.Collections.Generic;
using System.Text;

namespace System
{
    public static class StringExtensionMethods
    {
        public static bool IsNullOrWhiteSpace(this string theString) {
            if ( theString != null ) {
                foreach ( char c in theString ) {
                    if ( Char.IsWhiteSpace( c ) == false )
                        return false;
                }
            }

            return true;
        }
    }
}
&lt;/pre&gt;&lt;br /&gt;
Then you can call the method like this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c#&quot;&gt;Console.WriteLine( test1.IsNullOrWhiteSpace() );
&lt;/pre&gt;&lt;br /&gt;
Note that we can&#39;t make an equivalent static method using extension methods so it has to be used on a string reference.</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/5545017538680978457/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/03/knowdotnet-stringisnullorwhitespace.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/5545017538680978457'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/5545017538680978457'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/03/knowdotnet-stringisnullorwhitespace.html' title='KnowDotNet: String.IsNullOrWhiteSpace'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1118477949704984682.post-1284777498759991508</id><published>2011-03-04T03:10:00.000-08:00</published><updated>2011-04-25T19:39:34.079-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".net"/><category scheme="http://www.blogger.com/atom/ns#" term="KnowDotNet"/><title type='text'>KnowDotNet Introduction</title><content type='html'>This is the first in an potentially unending number of posts on classes, functions of the .Net Framework. It may include Visual Studio tips as I remember them or come across them.&lt;br /&gt;
&lt;br /&gt;
The goal of this series is simply to make myself (and you if your interested) more familiar with what is available in the .Net framwork in the way of classes or function etc. In brainstorming a few ideas I&#39;ve already come accross functions that I&#39;ve not noticed before which would have made my life a little easier as a programmer.&lt;br /&gt;
&lt;br /&gt;
Needless to say, this is probably going to be boring in some cases, but the .Net Framework has a massive amount of interesting and helful features, classes etc, that are impossible to use if you don&#39;t know they are there.&lt;br /&gt;
&lt;br /&gt;
Just incase someone asks, the idea came about while listening to Dot Net Rocks in which they dedicate a few minutes at the beginning of each episode to something in dot net. I thought the idea had merit. I think that spending a few minutes a day looking at something that I&#39;ve not used or even seen before, looking a bit closer at things I&#39;ve used frequently even, can be of great benefit.&lt;br /&gt;
&lt;br /&gt;
This is just an introduction, so keep your eye out for items with the tag KnowDotNet. The first few will probably be generally on the String class... It&#39;s a nice place to start :)</content><link rel='replies' type='application/atom+xml' href='http://jwwishart.blogspot.com/feeds/1284777498759991508/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jwwishart.blogspot.com/2011/03/knowdotnet-introduction.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/1284777498759991508'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1118477949704984682/posts/default/1284777498759991508'/><link rel='alternate' type='text/html' href='http://jwwishart.blogspot.com/2011/03/knowdotnet-introduction.html' title='KnowDotNet Introduction'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>