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

<channel>
	<title>C# Hacker - The Rambling Coder &#187; Development</title>
	<atom:link href="http://www.csharphacker.com/technicalblog/index.php/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.csharphacker.com/technicalblog</link>
	<description>Thoughts and ponderings on the technical world</description>
	<lastBuildDate>Thu, 22 Jul 2010 02:15:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>C# Code coverage approaches and unit tests</title>
		<link>http://www.csharphacker.com/technicalblog/index.php/2009/09/14/code-coverage-approaches-with-tdd/</link>
		<comments>http://www.csharphacker.com/technicalblog/index.php/2009/09/14/code-coverage-approaches-with-tdd/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 03:15:15 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.csharphacker.com/technicalblog/?p=442</guid>
		<description><![CDATA[This weekend I wrote a set of classes to [Determine and police password strength]. The interesting goal I set my self was to ensure that I got 100% code coverage using the MS unit test framework. Sounds easy! How hard can that be? Honestly I&#8217;ve focused more on TDD tests rather than code coverage. Well [...]]]></description>
			<content:encoded><![CDATA[<p>This weekend I wrote a set of classes to [<a href="/technicalblog/index.php/2009/09/13/better-way-to-determine-and-police-password-strengths/">Determine and police password strength</a>]. The interesting goal I set my self was to ensure that I got 100% code coverage using the MS unit test framework. Sounds easy! How hard can that be? Honestly I&#8217;ve focused more on TDD tests rather than code coverage.</p>
<p>Well firstly I have to say its not that easy <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> , secondarily it really shows the true benefit of [<a href="http://en.wikipedia.org/wiki/Test-driven_development">TDD</a>] &#8211; more on that later. So on to the discoveries!</p>
<p>Being a TDD advocate I started off with an interface and then the tests before the code. So far so good &#8211; then on to the code. As a Spongebob episode would say &#8220;Several hours later&#8221; we were done. So crank up the tests and we are looking golden.</p>
<p>Unfortunately the code coverage wasn&#8217;t half as good as I had hoped for. So next couple of hours was spent updating the tests for coverage, and a number of edge cases surrounding the throwing of exceptions for invalid parameters. Interestingly a couple of areas that showed up outside of the TDD approach were certain areas in &#8220;for loops&#8221; where not executed because my test case was really unknowingly best case. The part that was revealing to me was that the TDD is really a &#8220;business&#8221; driven approach, code coverage is believed to be a programmers indicator of  &#8216;quality&#8217;. So while TDD (at least the first pass I end up doing) meets the business needs it is very hard to get 100% coverage from a business scenario.</p>
<p>Finally I got it up to 99.84% coverage. This last standout was VERY annoying, specifically looking at the code coverage everything was green &#8211; no red or yellow sections. Hrrrmm. Ok it was a simple function that has this 1 block of unexecuted code &#8211; a switch statement taking a enum in as a parameter.  So lets have a look have a look (note I&#8217;ve stripped a lot of the content and comments out for readability:</p>
<pre class="brush: csharp;">
   public enum PasswordStrengthIndex
   {
      None = 0,
      Weak = 1,
      Medium = 2,
      Strong = 3,
      MostStrong = 4,
   }

      public void ResetToDefinedPolicyStrength(PasswordStrengthIndex strength)
      {
         switch (strength)
         {
            case PasswordStrengthIndex.None:
               MinimumPasswordLength = 0;
               break;
            case PasswordStrengthIndex.Weak:
               MinimumPasswordLength = 4;
               break;
            case PasswordStrengthIndex.Medium:
               MinimumPasswordLength = 6;
               break;
            case PasswordStrengthIndex.Strong:
               MinimumPasswordLength = 8;
               break;
            case PasswordStrengthIndex.MostStrong:
               MinimumPasswordLength = 12;
               break;
         }
         return;
      }
</pre>
<p>The test case iterated through the enums and verified the output matched the expectations. Still I had this annoying block that was unexecuted. The next step was the Jimmy Neutron &#8220;Think Think Think&#8221;, a-ha! No default handler &#8211; so add one. Hmmm I cant add one that actually can be exercised as I&#8217;ve already used all my values in my enum. Well adding a default handler to anyone of those case statements still didnt resolve the issue. Now it was getting personal! I was dangerously close to calling in technical gurus and venting my disgust! So before making the calls time to search Google for &#8220;Code Coverage Switch&#8221; &#8211; and boy Google never ceases to amaze me.</p>
<p>Firstly it confirmed my suspicion that is was indeed the switch statement, second was a link that explained it in detail. Basically the default  handler was not getting called &#8211; and there were a number of &#8216;breaking&#8217; workarounds (change the enum to have another element to be used in the default case) in the Google answers, but one one that I &#8216;liked&#8217; the most was to force the cast (which I would link out to the original author out of respect but I cant find it now <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />  ).</p>
<pre class="brush: csharp;">
      public void ResetToDefinedPolicyStrength(PasswordStrengthIndex strength)
      {
         switch (strength)
         {
            case PasswordStrengthIndex.None:
               MinimumPasswordLength = 0;
               break;
            case PasswordStrengthIndex.Weak:
               MinimumPasswordLength = 4;
               break;
            case PasswordStrengthIndex.Medium:
               MinimumPasswordLength = 6;
               break;
            case PasswordStrengthIndex.Strong:
               MinimumPasswordLength = 8;
               break;
            case PasswordStrengthIndex.MostStrong:
               MinimumPasswordLength = 12;
               break;
            default:
               throw new ArgumentException(&quot;Supplied strength is not recognized as enum&quot;, &quot;strength&quot;);
         }
         return;
      }

      [TestMethod()]
      [ExpectedException(typeof(ArgumentException))]
      public void ResetToDefinedPolicyStrengthBogus()
      {
         PasswordPolicy policy = new PasswordPolicy();
         policy.ResetToDefinedPolicyStrength(&lt;strong&gt;(PasswordStrengthIndex)666&lt;/strong&gt;);
      }
</pre>
<p>Look at the last line of the listing above. Use a cast to force the enum to be a number out side of the range it was looking for &#8211; ta da!  On a partially related note this reminds me of the fact Enums are definitely interesting beasts that can bite you if you have compiled against one then change its definition in a different assembly.</p>
<p>So now we have got to 100% code coverage &#8211; woo hoo! The realization (which is obvious and well know to many) is that without TDD you would most likely end up writing tests that cover your code &#8211; but miss the business requirements. So any programmers out there who think they have good code coverage but are not using TDD are likely to have a false believe in their code because the tool says 100% green (unless they are coding guru&#8217;s!) &#8211; they are only really testing what they have written and not the business requirements. On the flipside just writing TDD tests without coverage is highly unlikely to meet all the &#8216;code&#8217; edge cases (different than &#8216;business&#8217; edge cases). So the conclusion it that the blend of the two are the best, but yet still not perfect. You have to start with TDD, and then move to code coverage &#8211; business first, code second.</p>
<p>I&#8217;m hoping at some point management teams will start to understand that even with 100% executed code coverage there can still be bugs as its a data world we live in! Obviously I&#8217;m an optimist!</p>
<p>Gareth</p>
]]></content:encoded>
			<wfw:commentRss>http://www.csharphacker.com/technicalblog/index.php/2009/09/14/code-coverage-approaches-with-tdd/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Better way to determine and police Password Strengths</title>
		<link>http://www.csharphacker.com/technicalblog/index.php/2009/09/13/better-way-to-determine-and-police-password-strengths/</link>
		<comments>http://www.csharphacker.com/technicalblog/index.php/2009/09/13/better-way-to-determine-and-police-password-strengths/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 23:41:02 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.csharphacker.com/technicalblog/?p=435</guid>
		<description><![CDATA[Perhaps my Google search mo-jo has been acting up, but I could not find a good strong C# implementation for strong passwords (in fact I really couldn&#8217;t find much outside of logical cut &#38; paste of implementations of random Information entropy implementations) . They were all predicated on the relatively standard assessment that all submitted [...]]]></description>
			<content:encoded><![CDATA[<p>Perhaps my Google search mo-jo has been acting up, but I could not find a good strong C# implementation for strong passwords (in fact I really couldn&#8217;t find much outside of logical cut &amp; paste of implementations of random Information entropy implementations) . They were all predicated on the relatively standard assessment that all submitted passwords are random &#8211; uh huh!</p>
<p>For starters I recommend reading the article [<a href="http://en.wikipedia.org/wiki/Password_strength">http://en.wikipedia.org/wiki/Password_strength</a>]. This is a good article covering the relative strengths of passwords, and gives a guide for determining the strength of a random password and a human derived password.</p>
<p>The major problem with passwords are that humans need to remember them, or they write them down. In an interesting technology twist historically you only used to  have to worry about your co-workers having access/abusing  your password because there was implicit physical security in place &#8211; you could only log on if you were physically in the office.  As such at that time your biggest threat was your co-workers, unfortunately the secondary defense of physical location has effectively been removed with the internet and VPN technology.  So now your threat count has increased from the people you work with to the entire world! Add to this these people are financially motivated and can directly target you &#8211; its a whole lot scarier out there now!</p>
<p>So before jumping into the implementations we need to go through well known things to avoid to help improve password strength:</p>
<ul>
<li>Avoid sequences &#8211; keyboard or alphabet based (abcd, qwert, 1234, !@#$% etc)</li>
<li>Avoid dictionary words, especially common ones! Be aware that common misspellings are also used in dictionary based attacks &#8211; so unless your misspelling is VERY unusual then you can expect it to be in a dictionary!</li>
<li>Avoid <a href="http://en.wikipedia.org/wiki/Leet">leet/1337</a> password substitution of words (eg P@ssw0rd, M1cr0$0ft, 0\/\/n3d). Again these are now all in dictionaries, so while it may be harder to brute force &#8211; they are pretty trivial for a dictionary attack. Of course it doesnt hurt to be 1337, but it just really doesn&#8217;t help defend a targeted attack.</li>
<li>Avoid team names, socials, license names etc.</li>
</ul>
<p>Things to avoid to minimize compromise exposure:</p>
<ul>
<li>Use different passwords for different online accounts</li>
<li>Avoid using information about you that can be readily be found on the web as a password reset scheme. DOB, where you were born, school name etc.</li>
<li>If any account needs the most rigorous password control it is your email account. Nearly every online system ties back to an email account. If you need to reset a password, it normally goes to your email address. If that is compromised then that is really the opening of Pandora&#8217;s box.</li>
</ul>
<p>Alright, lets start with the weakest &#8216;safe&#8217; approach &#8211; Information entropy:</p>
<ul>
<li>This strength calculation only holds true for &#8216;random&#8217; passwords. No human (at least that I know) can really generate a random password on their own. The best approach that I&#8217;m aware of is to start up notepad and get your two year old to start smacking your keyboard. Then take this text and randomly change case of characters and inserting special characters. Unfortunately this is still weak because we have 2 hands and the keyboard is naturally divided into where your hands go. This generation is not as randomly distributed as people would think &#8211; nor would I recommend it! But at least you have a starting point, but then you have to write it down!</li>
<li>[0-9] &#8211; 10 possible symbols per character &#8211; 3.32 bits of base2 log entropy</li>
<li>[a-z] &#8211; 26 possible symbols per character- 4.7 bits of base2 log entropy</li>
<li>[A-Z] &#8211; 26 possible symbols per character- 4.7 bits of base2 log entropy</li>
<li>[A-Z, 0-9] &#8211; 36 possible symbols per character- 5.17 bits of base2 log entropy</li>
<li>[A-Z,a-z] &#8211; 52 possible symbols per character- 5.7 bits of base2 log entropy</li>
<li>[A-Z, a-z, 0-9] &#8211; 62 possible symbols per character- 5.95 bits of base2 log entropy</li>
<li>[A-Z, a-z, 0-9, Special] &#8211; 94 possible symbols per character &#8211; 6.55 bits of base2 log entropy</li>
</ul>
<p>So we can see that having a strong password using completely random information will be hard to generate on our own, yet this approach is what is what is most commonly used to in web applications to determine password strength. This is not strong enough because humans are naturally not random. Using this  theory the following non-random passwords generate results that imply the passwords are strong:</p>
<ul>
<li>12345678901234567890 &#8211; 20*3.32 =&gt; 66.4 bits of entropy</li>
<li>!!!!!!!!!!!!!!!!!!!! &#8211; 10 * 6.55 =&gt; 65.5 bits of entropy</li>
<li>!@#$%^&amp;*() &#8211; 10 &amp; 6.55 =&gt; 65.5 bits of entropy</li>
<li>qwertyuiop[]qwertyuiop[] = 24 * 6.55 =&gt; 157.2 bits of entropy.</li>
</ul>
<p>The more astute among us will see the last two passwords were generated by running your finger across the a keyboard line of on a US keyboard. To enter the 24 characters password took under 3 seconds. So if anyone saw someone entering a password like this at work or in a library &#8211; its pretty easy to duplicate. Plainly you can see that with human users they are going to opt for the easiest way to remember and enter a password &#8211; this will never be random!</p>
<p>So to help avoid our users from becoming victims we have to try to take away the &#8216;easy&#8217; passage from them. We have to assume the password is not going to be mathematically random &#8211; so we need to start from a different position. We have to ensure we remove the human weaknesses that other &#8216;black hats&#8217; are looking to exploit.</p>
<p>So going back to the beginning of the article we are going to create an interface to define a &#8216;password policy&#8217; that provides us a way to help enforce a stronger passwords &#8211; or  at least allows systems to setup a common language for handling passwords.</p>
<pre class="brush: csharp;">
   /// &lt;summary&gt;
   /// Interface for defining a password policy
   /// &lt;/summary&gt;
   /// &lt;remarks&gt;
   /// This security policy determines whether passwords
   /// meet pre-determined complexity requirements.
   ///
   /// If this policy is enabled, passwords must meet the
   /// following minimum requirements:
   ///
   /// Not contain the user's account name or parts of the
   /// user's full name that exceed four consecutive
   /// characters.
   /// Be at least &lt;see cref=&quot;MinimumPasswordLength&quot;/&gt;
   /// characters in length
   /// Contain characters from three of the following
   /// four categories:
   /// English uppercase characters (A through Z)
   /// English lowercase characters (a through z)
   /// Base 10 digits (0 through 9)
   /// Non-alphabetic characters (for example, !, $, #, %)
   ///
   /// Complexity requirements are enforced when passwords
   /// are changed or created.
   /// &lt;/remarks&gt;
   public interface IPasswordPolicy : IPolicy
   {
      /// &lt;summary&gt;
      /// Indicates the minimum password strength index for
      /// this policy (see PasswordStrengthIndex)
      /// &lt;/summary&gt;
      /// &lt;remarks&gt;
      /// This value is based of a calculation of
      /// information entropy after sequences
      /// and dictionary words have been
      /// removed.
      /// &lt;/remarks&gt;
      /// &lt;value&gt;
      /// The minimum index of the password strength.
      /// &lt;/value&gt;
      PasswordStrengthIndex MinimumPasswordStrengthIndex
      {
         get;
         set;
      }

      /// &lt;summary&gt;
      /// Gets or sets the minimum length of the password.
      /// &lt;/summary&gt;
      /// &lt;value&gt;The minimum length of the password.&lt;/value&gt;
      int MinimumPasswordLength
      {
         get;
         set;
      }

      /// &lt;summary&gt;
      /// Gets or sets the maximum length of the password.
      /// &lt;/summary&gt;
      /// &lt;value&gt;The maximum length of the password.&lt;/value&gt;
      int MaximumPasswordLength
      {
         get;
         set;
      }

      /// &lt;summary&gt;
      /// If policy requires mixed case
      /// &lt;/summary&gt;
      /// &lt;value&gt;true if policy needs mixed case&lt;/value&gt;
      bool RequireMixedCase
      {
         get;
         set;
      }

      /// &lt;summary&gt;
      /// If policy needs digits
      /// &lt;/summary&gt;
      /// &lt;value&gt;true if policy needs digits.&lt;/value&gt;
      bool RequireDigits
      {
         get;
         set;
      }

      /// &lt;summary&gt;
      /// If policy needs special characters
      /// &lt;/summary&gt;
      /// &lt;value&gt;
      /// true if require special characters are needed
      /// &lt;/value&gt;
      bool RequireSpecialCharacters
      {
         get;
         set;
      }

      /// &lt;summary&gt;
      /// Indicates if the username needs to be additionally
      /// supplied to verify the password complexity against
      /// &lt;/summary&gt;
      /// &lt;value&gt;
      /// true require username to check password against
      /// &lt;/value&gt;
      bool RequireUsernameToCheckPasswordAgainst
      {
         get;
         set;
      }

      /// &lt;summary&gt;
      /// Gets or sets the maximum count of characters
      /// in a sequence
      /// &lt;/summary&gt;
      /// &lt;value&gt;The maximum count of characters
      /// in a sequence.&lt;/value&gt;
      int MaximumCharacterSequenceCount
      {
         get;
         set;
      }

      /// &lt;summary&gt;
      /// The duration of the lockout in minutes.
      /// &lt;/summary&gt;
      /// &lt;remarks&gt;
      /// This security setting determines the number of
      /// minutes a locked-out account remains locked
      /// out before automatically becoming unlocked.
      /// The available range is from 0 minutes through
      /// 99,999 minutes.
      /// If you set the account lockout duration to less
      /// than zero, the account will be locked out until an
      /// administrator explicitly unlocks it. If an account
      /// lockout threshold is defined, the account lockout
      /// duration must be greater than or equal to
      /// the reset time.
      /// &lt;/remarks&gt;
      /// &lt;value&gt;The duration of the lockout.&lt;/value&gt;
      int LockoutDuration
      {
         get;
         set;
      }

      /// &lt;summary&gt;
      /// Gets or sets the lockout threshold.
      /// &lt;/summary&gt;
      /// &lt;remarks&gt;
      /// This security setting determines the number of
      /// failed logon attempts that causes a user
      /// account to be locked out. A locked-out
      /// account cannot be used until it is reset
      /// by an administrator or until the
      /// lockout duration for the account has expired. You
      /// can set a value between 0 and 999 failed
      /// logon attempts. If you set the value to 0,
      /// the account will never be locked out.
      /// &lt;/remarks&gt;
      /// &lt;value&gt;The lockout threshold.&lt;/value&gt;
      int LockoutThreshold
      {
         get;
         set;
      }

      /// &lt;summary&gt;
      /// Reset account lockout after X minutes
      /// &lt;/summary&gt;
      /// &lt;remarks&gt;
      /// This security setting determines the number of
      /// minutes that must elapse after a failed logon
      /// attempt before the failed logon attempt
      /// counter is reset to 0 bad logon attempts.
      /// The available range is 1 minute to
      /// 99,999 minutes.
      /// &lt;/remarks&gt;
      /// &lt;value&gt;The duration of the lockout.&lt;/value&gt;
      int LockoutResetInMinutes
      {
         get;
         set;
      }
   }
</pre>
<p>You can see this password policy template extends the initial outline to not only provide guidance for the number of entropy bits, but allows for the policy to cover the lock out strategy in the case of incorrect password handling and password expiry approaches. If you look at the source code you will also see the options that are available, but for the sake of this article we are trying to keep on point <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>So on to the actual strength testing, this oddly is rather simple at the end of the day. We are going to use an Interface definition (IPassword) for the Password processor (makes testing &amp; mocking easier) so we can actually have multiple implementations (think <a href="http://www.codeplex.com/MEF">MEF</a>!).  Now the actual implementation.</p>
<ol>
<li>Check for sequences using various lookup tables to determine if any sequences exist. If a sequence length is detected, and is longer than allowed the password fails the policy. The tables include:
<ul>
<li>Alphabetic + numeric sequence</li>
<li>QWERTY US Keyboard</li>
<li>QWERTY UK Keyboard</li>
<li>AZERTY Keyboard</li>
</ul>
</li>
<li>Perform simple DecodeEliteEncoding then perform a simple hardcoded dictionary match of well known super common passwords</li>
<li>If supplied (and if required) compare password elements to the user name</li>
</ol>
<p>The end implementation is still fairly simple and it would be fairly easy to improve on this implementation.  The most obvious ones are to support a custom dictionary and add more custom keyboard sequences. Other extensions would be to store the passwords and become a real password token service. We can leave it up to the reader to provide an implementation of IPassword to call the Google password rating service rather than the above implementation:</p>
<p><a href="https://www.google.com/accounts/RatePassword?Passwd=csharphacker">https://www.google.com/accounts/RatePassword?Passwd=csharphacker</a></p>
<p>All good stuff! I hope this helps (and the source code) people provide a better approach to helping strengthen passwords.</p>
<p style="text-align: center;"><strong>[<a href="http://www.csharphacker.com/CSharpHacker.Utils.zip">Download source code here</a>]</strong></p>
<p>The linked source code is liable to change over time so check back often. The source code uses the Microsoft testing framework and currently has 100% code coverage! Although I don&#8217;t think 100% is all that people think it is.</p>
<p>Finally the goal is to make everything a more secure place &#8211; and in reality the best approach is to use a strong memorable password in conjunction with a hardware token that changes every minute.</p>
<p>As always feedback is welcome!</p>
<p>Gareth</p>
]]></content:encoded>
			<wfw:commentRss>http://www.csharphacker.com/technicalblog/index.php/2009/09/13/better-way-to-determine-and-police-password-strengths/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>We all wanted the reason why we wanted to install Win 7 &#8211; right?</title>
		<link>http://www.csharphacker.com/technicalblog/index.php/2009/08/04/win-7-booting-to-vhd/</link>
		<comments>http://www.csharphacker.com/technicalblog/index.php/2009/08/04/win-7-booting-to-vhd/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 05:29:28 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.csharphacker.com/technicalblog/?p=420</guid>
		<description><![CDATA[Ok I admit I&#8217;ve been watching the clock tick closer to August 6th , but if you work with virtual machines (and you know who you are!) and have been ever frustrated by speed or it just not feeling normal then just check out the boot to VHD feature!: [The Virtualization Nation Podcast – Episode [...]]]></description>
			<content:encoded><![CDATA[<p>Ok I admit I&#8217;ve been watching the clock tick closer to August 6th <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> , but if you work with virtual machines (and you know who you are!) and have been ever frustrated by speed or it just not feeling normal then just check out the boot to VHD feature!:</p>
<ul>
<li>[<a href="http://blogs.msdn.com/mikekol/archive/2009/05/14/the-virtualization-nation-podcast-episode-3-want-to-boot-a-physical-computer-from-a-vhd.aspx">The Virtualization Nation Podcast – Episode 3: Want to boot a physical computer from a VHD?</a>]</li>
<li>[<a href="http://www.hanselman.com/blog/StepByStepTurningAWindows7DVDOrISOIntoABootableVHDVirtualMachine.aspx">Step-By-Step: Turning a Windows 7 DVD or ISO into a Bootable VHD Virtual Machine</a>]</li>
</ul>
<p>Seriously cool &#8211; I mean seriously! Native booting to a VHD on your disk &#8211; I want to buy who ever thought of that and got management to agree to putting that into Windows 7 (think HyperVisor) a beer!</p>
<p>I LOVE IT!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.csharphacker.com/technicalblog/index.php/2009/08/04/win-7-booting-to-vhd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GZipStream is helpful, but has some missing features</title>
		<link>http://www.csharphacker.com/technicalblog/index.php/2009/07/27/gzipstream-helper-gzip/</link>
		<comments>http://www.csharphacker.com/technicalblog/index.php/2009/07/27/gzipstream-helper-gzip/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 04:07:42 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.csharphacker.com/technicalblog/?p=411</guid>
		<description><![CDATA[I recently had to work around a problem in a particularly ugly way (which I wont detail ), so after that painful experience I opted to create a class to solve my specific issue in a sane and reusable manner! Out of this unexpected need the class &#8220;GZipHelper&#8221; was born. This is really just a [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had to work around a problem in a particularly ugly way (which I wont detail <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ), so after that painful experience I opted to create a class to solve my specific issue in a sane and reusable manner! Out of this unexpected need the class &#8220;GZipHelper&#8221; was born. This is really just a wrapper around the  base .Net <a href="http://msdn.microsoft.com/en-us/library/system.io.compression.gzipstream.aspx">System.IO.Compression.GZipStream</a> . Its was kind of a sad day as I really didn&#8217;t want to be doing this type of wrapper code, I was hoping it would have just been nativity available in the existing GZipStream class and I could have got on with solving my real business problem at hand.</p>
<p>Firstly it should be said that the standard GZipStream stream provides the functionality I&#8217;m sure the MS engineers expected it to do, which was for HTTP based compression (at least I think that was its expected purpose). However it is certainly not a fully featured class that is really easy to use for the programmers looking to get quick &amp; helpful access to the GZip compression.</p>
<p>Specifically the problem I needed to solved was I needed to know how big any given &#8220;.GZ&#8221; decompressed file was without fully reading and decompressing the file. It seemed trivial enough &#8211; &#8220;gzip.exe -l&#8221; does what I needed, but no amount of hunting within MSDN helped. So on to the ever handy <a href="http://en.wikipedia.org/wiki/Gzip">GZip wikipedia</a> entry that detailed enough of the file format and provided the reference to the &#8220;<a href="http://tools.ietf.org/html/rfc1952">GZIP file format specification version 4.3</a>&#8220;.</p>
<p>So armed this this information we can start to decode the GZip file format to extract the length. Infact this class will check the file to see if it is GZip compressed and returns the decompressed length for that or the regular file length if it is not compressed.</p>
<p>The following class functions have been implemented (see the bottom of the article for the link to the full project):</p>
<pre class="brush: csharp;">
   /// &lt;summary&gt;
   /// Utility class to help with managing GZip (.gz) files in .Net
   /// &lt;/summary&gt;
   /// &lt;remarks&gt;
   /// This is a trivial wrapper class on top of &lt;see cref=&quot;GZipStream&quot;/&gt; that does a little magic
   /// under the covers by looking at the underlying data format and retrieves the
   /// stored data information within the GZip compressed file.
   /// &lt;/remarks&gt;
   public class GZipHelper
   {
      /// &lt;summary&gt;
      /// Gets the compressed file details
      /// &lt;/summary&gt;
      /// &lt;param name=&quot;filename&quot;&gt;The filename.&lt;/param&gt;
      /// &lt;returns&gt;True if file exists, else false&lt;/returns&gt;
      public bool GetFileDetails(string filename);

      /// &lt;summary&gt;
      /// Gets the compressed file information from a file stream
      /// &lt;/summary&gt;
      /// &lt;param name=&quot;fileStream&quot;&gt;The file stream.&lt;/param&gt;
      /// &lt;remarks&gt;
      /// Definitions provided by RFC 1952 -GZIP File Format Specification (May 1996).
      /// Coding was performed against ftp://ftp.isi.edu/in-notes/rfc1952.txt
      /// &lt;/remarks&gt;
      public void GetFileInformation(FileStream fileStream);

      /// &lt;summary&gt;
      /// Compresses the file file
      /// &lt;/summary&gt;
      /// &lt;param name=&quot;filename&quot;&gt;The filename.&lt;/param&gt;
      /// &lt;param name=&quot;overWriteExisting&quot;&gt;if set to &lt;c&gt;true&lt;/c&gt; [over write existing].&lt;/param&gt;
      /// &lt;returns&gt;&lt;/returns&gt;
      public void CompressFile(string filename, bool overWriteExisting);

      /// &lt;summary&gt;
      /// Decompresses the file.
      /// &lt;/summary&gt;
      /// &lt;param name=&quot;filename&quot;&gt;The filename.&lt;/param&gt;
      /// &lt;param name=&quot;overWriteExisting&quot;&gt;if set to &lt;c&gt;true&lt;/c&gt; [over write existing].&lt;/param&gt;
      /// &lt;returns&gt;&lt;/returns&gt;
      public bool DecompressFile(string filename, bool overWriteExisting);

      /// &lt;summary&gt;
      /// Returns a seekable stream into either a file or compressed file (defaults read-only)
      /// &lt;/summary&gt;
      /// &lt;remarks&gt;
      /// Decompresses the stream into a &lt;see cref=&quot;MemoryStream&quot;/&gt; if the file is compressed
      /// otherwise just returns back a regular &lt;see cref=&quot;FileStream&quot;/&gt; as a &lt;see cref=&quot;Stream&quot;/&gt;
      /// &lt;/remarks&gt;
      /// &lt;param name=&quot;filename&quot;&gt;The filename to open.&lt;/param&gt;
      /// &lt;returns&gt;Reference to opened stream&lt;/returns&gt;
      public Stream GetSeekableStream(string filename);
   }
</pre>
<p>In combination to this the following properties are available:</p>
<ul>
<li>CompressedLength &#8211; Size of the compressed file (or regular file size if not compressed)</li>
<li>DecompressedLength &#8211; Size of the file if it were uncompressed (or regular file size if not compressed)</li>
<li>IsTextFile &#8211; Indicates if GZip thought the file was text based, potentially leading to better compression</li>
<li>CompressionModeValue &#8211; Numeric indication of the compression mode used</li>
<li>CRC16Present &#8211; Indicates a CRC16 is available for the file</li>
<li>ExtraFieldsPresent &#8211; Additional meta fields are available in the file</li>
<li>FileNamePresent &#8211; GZip contains the original file name</li>
<li>FileCommentPresent &#8211; Compressed file has a comment associated with it</li>
<li>IsCompressed &#8211; Indicates if the file is GZip compressed or not</li>
<li>CompressedDate &#8211; If stored this is the date the file was compressed.</li>
<li>CRC32 &#8211; CRC32 value associated with the file</li>
</ul>
<p>Along with the project there are MSTest harnesses to test the class (trivial implementations). So the features of the class are:</p>
<ul>
<li>Can trivially determine a true file size (regardless if it was compressed via GZip or is uncompressed). This makes your code path much more readable if you are dealing with mixed file types.</li>
<li>Provides a Seekable stream into the compressed file via via a MemoryStream. The key is that you dont need to worry about the compression  (unless you are reading in BIG files) as you will get back a Stream for either a File or a Compressed file &#8211; both support seeking. This can be handy if you problem assumes it can Seek in the stream and you need to access GZip files!</li>
<li>Trivial Decompress file, this also honors the CompressedDate. If that date is set then the decompressed file has that creation date.</li>
<li>Trivial Compress file. Unfortunately at the time of writing I&#8217;ve not updated the header to include the date of the compressed file. This may come in a later version (and if so I&#8217;ll update the blog <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  &#8211; but definitely no promises!).</li>
</ul>
<p>Simple example usages are (taken straight from the unit tests!):</p>
<pre class="brush: csharp;">

// Perform a file compression
GZipHelper actual = new GZipHelper();
actual.CompressFile(_fileName, true);

// Perform a file decompression
GZipHelper actual = new GZipHelper();
string fileName = &quot;CSharpHackerSmallTest.txt.gz&quot;;
actual.DecompressFile(fileName, true);

// Get a seekable stream
GZipHelper actual = new GZipHelper();
using (Stream dataStream = actual.GetSeekableStream(&quot;CSharpHackerSmallTest.txt.gz&quot;))
{
    // Silly seek - but it just shows it can be done
    dataStream.Seek(0, SeekOrigin.Begin);
    StreamReader sr = new StreamReader(dataStream);
    string contents = sr.ReadToEnd();

    Assert.AreEqual(119, contents.Length);
}

// Gets natural decompressed file length from a compressed file.
GZipHelper actual = new GZipHelper();
actual.GetFileInformation(&quot;CSharpHackerSmallTest.txt.gz&quot;);
Assert.AreEqual(119, actual.DecompressedLength);
</pre>
<p>Finally it should be noted that by all accounts the standard implementation of GZipStream in the base .Net libraries (actually the DeflateStream) has a problem when attempting to compress random or already compressed data. There is a Microsoft Connect article [<a href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=93930">http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=93930</a>] that details the issue.</p>
<blockquote><p>The GZipStream and DeflateStream classes can _significantly_ increase the size of &#8220;compressed&#8221; data. That means, they don&#8217;t just add a few header bytes as stand-alone compressors do, but they _inflate_ the data by as much as 50%. This is apparently because these classes do not check for incompressible data which is a standard feature of all stand-alone compressors. Both classes work fine when the data actually can be compressed.</p>
<p>Please refer to this thread for more details:</p>
<p>http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=179704&amp;SiteID=1</p></blockquote>
<p>The base implementation worked for me and met my specific needs without the need of bringing in any third party DLLs. Which incidentally also has a nice benefit for those looking to bring this into proprietary software of avoiding any licensing discussions with supervisors! If you want a more robust GZipStream implementation you can check out <a href="http://dotnetzip.codeplex.com/">http://dotnetzip.codeplex.com/</a>. This apparently has a drop in replacement, but this class could still be useful even if use this drop in replacement as well.</p>
<p>I hope this helps some one out there <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<blockquote>
<p style="text-align: center;">[<a href="http://www.csharphacker.com/GZipHelper.zip">Download GZipHelper (Source + Project) Here</a>]</p>
</blockquote>
<p>This download link will always have the latest and greatest version.</p>
<p>Gareth</p>
]]></content:encoded>
			<wfw:commentRss>http://www.csharphacker.com/technicalblog/index.php/2009/07/27/gzipstream-helper-gzip/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CLR, DLLs and a blast from the past</title>
		<link>http://www.csharphacker.com/technicalblog/index.php/2009/07/21/clr-dlls-ngen-base-address-performance/</link>
		<comments>http://www.csharphacker.com/technicalblog/index.php/2009/07/21/clr-dlls-ngen-base-address-performance/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 12:49:47 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.csharphacker.com/technicalblog/?p=401</guid>
		<description><![CDATA[The CLR and performance folks have told us old timers that some things never change , although if you read closely it does! [A primer on setting base-addresses for managed DLLs] covers how for performance reasons you probably want to [NGen] your code (on the remote computer) and ensure you have your base-addresses setup to [...]]]></description>
			<content:encoded><![CDATA[<p>The CLR and performance folks have told us old timers that some things never change <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> , although if you read closely it does!</p>
<p><a href="http://blogs.msdn.com/clrperfblog/archive/2009/07/17/a-primer-on-setting-base-addresses-for-managed-dlls.aspx">[A primer on setting base-addresses for managed DLLs]</a> covers how for performance reasons you probably want to <a href="http://msdn.microsoft.com/en-us/library/6t9t5wcf%28VS.80%29.aspx">[NGen] </a>your code (on the remote computer) and ensure you have your base-addresses setup to avoid clashes. The interesting thing is that with <a href="http://en.wikipedia.org/wiki/Address_space_layout_randomization">[ASLR] </a>enabled on VISTA, Windows 7, Windows Server 2008 and higher it doesnt help <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<p>So for the performance conscious .net coders out there targetting fast startups definitely have a read.</p>
<p>Gareth</p>
]]></content:encoded>
			<wfw:commentRss>http://www.csharphacker.com/technicalblog/index.php/2009/07/21/clr-dlls-ngen-base-address-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Failure to run unit tests with DLL “is not trusted”?</title>
		<link>http://www.csharphacker.com/technicalblog/index.php/2009/07/19/failure-to-run-unit-tests-with-dll-%e2%80%9cis-not-trusted%e2%80%9d/</link>
		<comments>http://www.csharphacker.com/technicalblog/index.php/2009/07/19/failure-to-run-unit-tests-with-dll-%e2%80%9cis-not-trusted%e2%80%9d/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 02:55:54 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.csharphacker.com/technicalblog/?p=396</guid>
		<description><![CDATA[Interestingly this is the first time I’ve come across this, I presume predominately because I try to only use DLL’s I’ve compiled myself and Firefox and the UNZIP tool I used never used to have this security ‘feature’. When I was doing some unit tests I got this message Failed to queue test run &#8216;Gareth@Monster [...]]]></description>
			<content:encoded><![CDATA[<p>Interestingly this is the first time I’ve come across this, I presume predominately because I try to only use DLL’s I’ve compiled myself and Firefox and the UNZIP tool I used never used to have this security ‘feature’.</p>
<p>When I was doing some unit tests I got this message</p>
<blockquote><p>Failed to queue test run &#8216;Gareth@Monster 2009-07-19 21:41:43&#8242;: Test Run deployment issue: The location of the file or directory &#8216;d:\home\git\filehash\filehashtest\bin\debug\System.Data.SQLite.dll&#8217; is not trusted.</p></blockquote>
<p>This has all to do with me trying to be a good boy and downloading the latest DLL from web to ensure I was developing and testing on the absolute latest version. This helpful &#8216;magic&#8217; is the Microsoft “Attachment Manager” that was introduced in XP SP2. Now it seems that both Firefox and WinZip 10 honor this feature (<a href="http://www.winzip.com/xattmgr.htm">http://www.winzip.com/xattmgr.htm</a>) so if you unzip a file using Winzip that has been tagged as ‘from the internet’ the unzip then tags all the files coming out as ‘blocked’.</p>
<p>There are a varying number of solutions:</p>
<h2>Option 1 – Pinpoint accuracy</h2>
<p>Select the properties on the file in question and press “Unblock”.</p>
<div id="attachment_398" class="wp-caption aligncenter" style="width: 374px"><img class="size-full wp-image-398" title="AttachmentManagerBlocking" src="http://www.csharphacker.com/technicalblog/wp-content/uploads/2009/07/AttachmentManagerBlocking.jpg" alt="Attachment Manager Blocking In Action" width="364" height="507" /><p class="wp-caption-text">Attachment Manager Blocking In Action</p></div>
<p>Good if you only have 1 file to deal with, bad if you have a large number of them! Unfortunately there is no good way to do this via a multi-select option, but remember if they all came from a ZIP file un ‘block’ the ZIP before performing the UNZIP!</p>
<h2>Option 2 – ‘The ultimate sledge hammer’ – definitely for the brave</h2>
<p>I dont recommend this!! However if you are feeling brave (and this is a personal PC and not a corporate one!) this feature can be disabled using search for “Do not preserve zone information in file attachments” in the link <a href="http://support.microsoft.com/default.aspx/kb/883260">http://support.microsoft.com/default.aspx/kb/883260</a> &#8211; its a ways down!</p>
<p>This won&#8217;t remove alternate streams from existing files. Also this &#8216;might&#8217; have side effects so use with caution.</p>
<p>In theory the Attachment Manager can be disabled via gpedit.msc. I say in theory because I cant see the option I’m going to write about (<a href="http://www.lansa.com/support/notes/p0348.htm">http://www.lansa.com/support/notes/p0348.htm</a>)</p>
<p>The steps to do that are outlined below:</p>
<ol>
<li>Run the &#8216;Group Policy Object Editor&#8217; (gpedit.msc) either from the Command Prompt or using the &#8216;Run&#8217; command in the Windows Start Menu</li>
<li>Expand the node &#8216;User Configuration&#8217; &gt;&gt; &#8216;Administrative Templates&#8217; &gt;&gt; &#8216;Windows Components&#8217; &gt;&gt; &#8216;Attachment Manager&#8217;.</li>
<li>Right-click on the third option: Do not preserve zone information in file attachments. Choose &#8216;Properties&#8217;.</li>
</ol>
<h2>Option 3 – Using Streams (for the script folks – and still a little brave!)</h2>
<p>Download the handy dandy ‘streams’ from <a href="http://technet.microsoft.com/en-us/sysinternals/bb897440.aspx">http://technet.microsoft.com/en-us/sysinternals/bb897440.aspx</a>. Then run “Streams -d –s c:\yourdirectorywithblockedfiles” this will recurse through all the folders deleting any streams it comes across. Beware some programs may be using streams for storage, if they are you will be deleting that meta data. But if this is only in a development folder you should be OK (make sure you have backups!)</p>
<h2>Option 4 – Copy all the affected files to a FAT file system and copy them back</h2>
<p>Title says it all, since streams are not supported on FAT file systems performing this copy to a FAT system and then back to NTFS ‘removes’ the offending streams.</p>
<p>Good luck <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.csharphacker.com/technicalblog/index.php/2009/07/19/failure-to-run-unit-tests-with-dll-%e2%80%9cis-not-trusted%e2%80%9d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell, Its time to update to the new scripting way!</title>
		<link>http://www.csharphacker.com/technicalblog/index.php/2009/07/18/powershell-its-time-to-update-to-the-new-scripting-way/</link>
		<comments>http://www.csharphacker.com/technicalblog/index.php/2009/07/18/powershell-its-time-to-update-to-the-new-scripting-way/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 20:45:27 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.csharphacker.com/technicalblog/?p=390</guid>
		<description><![CDATA[I suspect everyone (at least reading this) is minimally aware of Powershell. The question is how much have you used it, and I mean &#8216;really used it&#8217;? I know I&#8217;ve been happily been using JP Software TCC LE (formally 4DOS, then 4NT) for ages, and for those wondering I am a console junkie &#8211; not [...]]]></description>
			<content:encoded><![CDATA[<p>I suspect everyone (at least reading this) is minimally aware of <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx">Powershell</a>. The question is how much have you used it, and I mean &#8216;really used it&#8217;? I know I&#8217;ve been happily been using <a href="http://www.jpsoft.com/tccledes.htm">JP Software TCC LE</a> (formally 4DOS, then 4NT) for ages, and for those wondering I am a console junkie &#8211; not really a great fan of Explorer. As an aside  I do wholeheartedly recommend the JP software TCC LE, that definitely gets my thumbs up!</p>
<p>So I&#8217;m finally taking the plunge as PowerShell 2.0 is about to come out. Firstly I&#8217;ll cover why I&#8217;m now making the move rather than before, then will provide some good links to help get your skills up!</p>
<h3>Why update now?</h3>
<p>Well Powershell has been out for a long time now, but the big differentiator is that it is now coming part of the standard Windows OS release (Windows 2008, Windows 7) rather than being an additional download. For any developer that has to support 3rd party systems (aka systems you dont own) you ideally want to stick to the standard tools installed on the machine rather than having to get a number of pre-requisites.  As it is only installed by default on a small section of machines its far from a slam dunk &#8211; but once it gets into the OS distribution we can be fairly sure its going to be mainstream and remain supported!</p>
<h3>Memory footprint</h3>
<p>So on to most commonly cited downside made by memory conscious folks, so lets get that out of the way!</p>
<p>Randomly Performed on my Windows XP (SP3) &#8211; these are definitely not exact but should show orders of magnitude.</p>
<ul>
<li>Command &#8211; Cmd.exe &#8211; Mem Usage 2,572Kb, VMSize 2,008Kb</li>
<li>TCC LE &#8211; TCC.exe &#8211; Mem Usage 3400Kb, VMSize 2,944Kb</li>
<li>Powershell 1.0 &#8211; Powershell.exe &#8211; Mem Usage 25,324, VMSize 22,668Kb</li>
</ul>
<p>So obviously it is definitely an order of magnitude heavier than historic command shell implementations. There are several reasons for this, the biggest is that the shell uses a plug-in architecture so you can seamlessly add your own &#8216;cmdlets&#8217; into the shell. Understandably if you start to run cmdlets (and most everything is a cmdlet) your memory foot print starts to go up as they get loaded into the process. For example if you run &#8220;PS&#8221;  to get a list of running processes your memory footprint will change as that module is loaded and executed. So if you are only concerned about memory footprints you should stop reading now &#8211; but if you are looking for functionality this is where PowerShell really shines!</p>
<h3>Standard Cmd.exe like Navigation</h3>
<p>After starting up powershell (&#8220;Start/Run/Powershell&#8221;) you start with a command like prompt. In my case its:</p>
<p>PS C:\Documents and Settings\csharphacker&gt;</p>
<p>From here you can do the normal things:</p>
<ul>
<li>CD &#8211; Change Directory</li>
<li>DIR &#8211; Directory listing</li>
<li>REN &#8211; Rename</li>
<li>DEL/ERASE &#8211; Delete</li>
<li>PUSHD &#8211; Push current location to stack</li>
<li>POPD &#8211; Pop last location from stack</li>
<li>CLS &#8211; Clear Screen</li>
<li>COPY &#8211; Copy file</li>
</ul>
<p>Also notice there is tab completion of file names <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> , now standardly available &#8211; but a killer not to have!</p>
<p>For Unix folks running on Windows there are Unix equivilents</p>
<ul>
<li>LS &#8211; Directory List</li>
<li>RM &#8211; Remove file</li>
<li>PWD &#8211; Current directory</li>
<li>PS &#8211; Process list</li>
<li>CAT &#8211; Output contents of file</li>
</ul>
<p>Still pretty standard stuff. As you look closer you will see that infact these are not build-in commands, but actually aliases to other commands within the shell.</p>
<pre>CommandType     Name                            Definition
-----------     ----                            ----------
Alias           ac                              Add-Content
Alias           asnp                            Add-PSSnapin
Alias           clc                             Clear-Content
Alias           cli                             Clear-Item
Alias           clp                             Clear-ItemProperty
Alias           clv                             Clear-Variable
Alias           cpi                             Copy-Item
Alias           cpp                             Copy-ItemProperty
Alias           cvpa                            Convert-Path
Alias           diff                            Compare-Object
Alias           epal                            Export-Alias
Alias           epcsv                           Export-Csv
Alias           fc                              Format-Custom
Alias           fl                              Format-List
Alias           foreach                         ForEach-Object
Alias           %                               ForEach-Object
Alias           ft                              Format-Table
Alias           fw                              Format-Wide
Alias           gal                             Get-Alias
Alias           gc                              Get-Content
Alias           gci                             Get-ChildItem
Alias           gcm                             Get-Command
Alias           gdr                             Get-PSDrive
Alias           ghy                             Get-History
Alias           gi                              Get-Item
Alias           gl                              Get-Location
Alias           gm                              Get-Member
Alias           gp                              Get-ItemProperty
Alias           gps                             Get-Process
Alias           group                           Group-Object
Alias           gsv                             Get-Service
Alias           gsnp                            Get-PSSnapin
Alias           gu                              Get-Unique
Alias           gv                              Get-Variable
Alias           gwmi                            Get-WmiObject
Alias           iex                             Invoke-Expression
Alias           ihy                             Invoke-History
Alias           ii                              Invoke-Item
Alias           ipal                            Import-Alias
Alias           ipcsv                           Import-Csv
Alias           mi                              Move-Item
Alias           mp                              Move-ItemProperty
Alias           nal                             New-Alias
Alias           ndr                             New-PSDrive
Alias           ni                              New-Item
Alias           nv                              New-Variable
Alias           oh                              Out-Host
Alias           rdr                             Remove-PSDrive
Alias           ri                              Remove-Item
Alias           rni                             Rename-Item
Alias           rnp                             Rename-ItemProperty
Alias           rp                              Remove-ItemProperty
Alias           rsnp                            Remove-PSSnapin
Alias           rv                              Remove-Variable
Alias           rvpa                            Resolve-Path
Alias           sal                             Set-Alias
Alias           sasv                            Start-Service
Alias           sc                              Set-Content
Alias           select                          Select-Object
Alias           si                              Set-Item
Alias           sl                              Set-Location
Alias           sleep                           Start-Sleep
Alias           sort                            Sort-Object
Alias           sp                              Set-ItemProperty
Alias           spps                            Stop-Process
Alias           spsv                            Stop-Service
Alias           sv                              Set-Variable
Alias           tee                             Tee-Object
Alias           where                           Where-Object
Alias           ?                               Where-Object
Alias           write                           Write-Output
Alias           cat                             Get-Content
Alias           cd                              Set-Location
Alias           clear                           Clear-Host
Alias           cp                              Copy-Item
Alias           h                               Get-History
Alias           history                         Get-History
Alias           kill                            Stop-Process
Alias           lp                              Out-Printer
Alias           ls                              Get-ChildItem
Alias           mount                           New-PSDrive
Alias           mv                              Move-Item
Alias           popd                            Pop-Location
Alias           ps                              Get-Process
Alias           pushd                           Push-Location
Alias           pwd                             Get-Location
Alias           r                               Invoke-History
Alias           rm                              Remove-Item
Alias           rmdir                           Remove-Item
Alias           echo                            Write-Output
Alias           cls                             Clear-Host
Alias           chdir                           Set-Location
Alias           copy                            Copy-Item
Alias           del                             Remove-Item
Alias           dir                             Get-ChildItem
Alias           erase                           Remove-Item
Alias           move                            Move-Item
Alias           rd                              Remove-Item
Alias           ren                             Rename-Item
Alias           set                             Set-Variable
Alias           type                            Get-Content
</pre>
<p>So if you start to look at this list you will begin to understand why this is a bigger beast than CMD or TCC LE will ever be.  However it has to be said that these commands are not &#8220;identical&#8221; to your preferred flavor &#8211; but more of a likeness to it. So LS doesnt have exactly the same characteristics, the same was that DIR doesn&#8217;t either &#8211; but the &#8216;intent is the same&#8217;.</p>
<p>The best keyboard shortcut for me is F8 (but I want to remap it to the up arrow!)  &#8211; read more about shortcuts can be found <a href="http://www.microsoft.com/technet/scriptcenter/topics/winpsh/manual/hotkeys.mspx">here</a>.</p>
<p>Recommended Reading Links (I should point out I am not affiliated with any of the below, but they are what I have used to get more acquainted with PowerShell) :</p>
<ul>
<li><a href="http://www.microsoft.com/technet/scriptcenter/topics/winpsh/manual/default.mspx">Microsoft Powershell Owners Manual</a>
<ul>
<li>Great starting place to this scripting beastie! Have a look at the chapters here &#8211; excellent material.</li>
</ul>
</li>
<li><a href="http://technet.microsoft.com/en-us/scriptcenter/dd742419.aspx">Scripting with Windows PowerShell</a>
<ul>
<li>Highly recommended as a starting place on PowerShell</li>
</ul>
</li>
<li>Free PowerShell book “<a href="http://powershell.com/cs/blogs/ebook/">Mastering PowerShell</a>”
<ul>
<li>500+ pages of well written handy examples</li>
</ul>
</li>
</ul>
<p>After reading these you should have a better understanding of the power of power shell. If using PowerShell to read/manipulate the registry, open CSV files, perform credential maintenance via script still doesnt make you want to learn it then remember that SQL 2008 has Powershell integration. So now you can browse your SQL schema using PowerShell as well.</p>
<p>This is where we can say for a certainty &#8220;Microsoft has started to take scripting seriously&#8221;!</p>
<p>Pretty cool stuff,<br />
Gareth</p>
]]></content:encoded>
			<wfw:commentRss>http://www.csharphacker.com/technicalblog/index.php/2009/07/18/powershell-its-time-to-update-to-the-new-scripting-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Azure Pricing Announced&#8230;.</title>
		<link>http://www.csharphacker.com/technicalblog/index.php/2009/07/14/azure-pricing-announced/</link>
		<comments>http://www.csharphacker.com/technicalblog/index.php/2009/07/14/azure-pricing-announced/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 21:35:27 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.csharphacker.com/technicalblog/?p=368</guid>
		<description><![CDATA[Finally we have the details we have all been waiting for, unfortunately its more of a wimper or even worse &#8220;me too&#8221; pricing model. The official information can be found below: http://blogs.msdn.com/windowsazure/ http://blogs.msdn.com/windowsazure/archive/2009/07/14/confirming-commercial-availability-and-announcing-business-model.aspx Fundamentally the problem for me is that it is competing head to head with Amazon with no clear winner. Infact Amazon not [...]]]></description>
			<content:encoded><![CDATA[<p>Finally we have the details we have all been waiting for, unfortunately its more of a wimper or even worse &#8220;me too&#8221; pricing model.</p>
<p>The official information can be found below:</p>
<ul>
<li><a href="http://blogs.msdn.com/windowsazure/">http://blogs.msdn.com/windowsazure/</a></li>
<li><a href="http://blogs.msdn.com/windowsazure/archive/2009/07/14/confirming-commercial-availability-and-announcing-business-model.aspx">http://blogs.msdn.com/windowsazure/archive/2009/07/14/confirming-commercial-availability-and-announcing-business-model.aspx</a></li>
</ul>
<p>Fundamentally the problem for me is that it is competing head to head with Amazon with no clear winner. Infact Amazon not only has a small price advantage with their Linux offering, but they have it all running with lots of infrastructure setup over many years. They are the defacto &#8216;standard&#8217; and they are cheaper on Linux and only a tiny bit more expensive on Windows!</p>
<p>Unfortunately at first blush this doesnt seem to be a business compelling reason to switch to Azure, and evaluation which one are you going to choose? A company that has been doing it for years and has been maturing their model and offerings or the new one to the block. I&#8217;m sure Microsoft will change their pricing model &#8211; but it appears to be a surprisingly weak opening offer from Microsoft.</p>
<p>A new news/blog articles covering this can be found here:</p>
<ul>
<li><a href=" http://www.theregister.co.uk/2009/07/14/microsoft_azure_cloud_price/">Microsoft&#8217;s Azure cloud price pipped by Amazon&#8217;s Linux</a></li>
<li><a href="http://blogs.conchango.com/simonmunro/archive/2009/07/14/azure-announces-unimaginative-pricing-model.aspx">Azure Announces Unimaginative Pricing Model</a></li>
</ul>
<p>Thoughts? Am I missing something fundamental here?</p>
<p>Gareth</p>
]]></content:encoded>
			<wfw:commentRss>http://www.csharphacker.com/technicalblog/index.php/2009/07/14/azure-pricing-announced/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Morning News 2009-07-14</title>
		<link>http://www.csharphacker.com/technicalblog/index.php/2009/07/14/morning-news-2009-07-14/</link>
		<comments>http://www.csharphacker.com/technicalblog/index.php/2009/07/14/morning-news-2009-07-14/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 13:57:11 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PCI]]></category>

		<guid isPermaLink="false">http://www.csharphacker.com/technicalblog/?p=365</guid>
		<description><![CDATA[A fair bit of news recently: AWS Start-Up Challenge For 2009 &#8211; Amazon has kicked off the third annual AWS Start-Up Challenge now. Start-ups in the United States, the United Kingdom, Germany, and Israel are encouraged to apply for a chance to win $50,000 in cash, $50,000 in AWS credits, mentoring sessions from AWS technical [...]]]></description>
			<content:encoded><![CDATA[<p>A fair bit of news recently:</p>
<ul>
<li><a href="http://aws.typepad.com/aws/2009/07/aws-startup-challenge-2009.html">AWS Start-Up Challenge For 2009</a> &#8211; Amazon has kicked off the third annual AWS Start-Up Challenge now.
<ul>
<li>Start-ups in the United States, the United Kingdom, Germany, and Israel are encouraged to apply for a chance to win $50,000 in cash, $50,000 in <span>AWS</span> credits, mentoring sessions from <span>AWS</span> technical experts, and <span>AWS</span> Premium Support Gold for one year.</li>
</ul>
</li>
<li><a href="http://sqlblogcasts.com/blogs/madhivanan/archive/2009/07/11/cte-in-a-view.aspx">How to use a CTE in a view</a>. If you dont know what a CTE is check it out <a href="http://msdn.microsoft.com/en-us/library/ms190766.aspx">here</a>, definitely check out its recursive capabilities <a href="http://sqlblogcasts.com/blogs/tonyrogerson/archive/2008/05/11/common-table-expressions-cte-s-how-it-works-how-recursion-works-using-with-adjacency-list.aspx">here</a>.</li>
<li>Microsoft Research &#8220;<a href="http://arstechnica.com/microsoft/news/2009/07/gazelle-microsofts-browser-os-is-not-actually-an-os.ars">Gazelle</a>&#8221; fires experimental salvo at Google.</li>
<li><a href="http://information-security-resources.com/2009/07/11/pci-dss-legitimizes-conflicts-of-interest/">PCI DSS Legitimizes Conflicts of Interest</a></li>
<li><a href="http://blogs.msdn.com/vbertocci/archive/2009/07/13/the-geneva-suite-of-products-get-official-names.aspx">Geneva identity grows up with rebranding</a> roll on Active Directory Federation Services (ADFS), Windows Identity Foundation &amp; Windows CardSpace.</li>
<li><a href="http://blogs.msdn.com/brada/archive/2009/07/13/managed-extensibility-framework-mef-preview-6-silverlight-support-and-much-more.aspx">Managed Extensibility Framework (MEF) Preview 6: V1 Feature Complete Silverlight Support and Much More!</a>
<ul>
<li>Not only is this the feature complete build for MEF V1.0 (which will ship with .NET Framework 4) but it also has the first drop of MEF for Silverlight!</li>
</ul>
</li>
<li><a href="http://www.techworld.com.au/article/310857/google_releases_open_source_nx_server">Google releases remote screen viewer</a> NeatX.
<ul>
<li>“The good old X Window system can be used over the network, but it has issues with network latency and bandwidth. Neatx remedies some of these issues,” Google engineers wrote on the <a href="http://google-opensource.blogspot.com/2009/07/releasing-neatx-open-source-nx-servier.html">company&#8217;s open source blog</a>.</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.csharphacker.com/technicalblog/index.php/2009/07/14/morning-news-2009-07-14/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to write SHA256Sum in C# (or MD5Sum, SHA1Sum)</title>
		<link>http://www.csharphacker.com/technicalblog/index.php/2009/07/12/how-to-write-sha256sum-in-c-or-md5sum-sha1sum/</link>
		<comments>http://www.csharphacker.com/technicalblog/index.php/2009/07/12/how-to-write-sha256sum-in-c-or-md5sum-sha1sum/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 04:00:59 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.csharphacker.com/technicalblog/?p=354</guid>
		<description><![CDATA[If you haven't come across MD5Sum.exe, SHA1Sum.exe, SHA256Sum.exe you can find native Windows ports here (or if you are looking for the more official GNU versions they can be found here) . Which if you are just looking for the command line tools that is probably enough. However sometimes you may have the need to do all this work yourselves in C#, if so this is the article that should help guide you! This details how to achieve ...]]></description>
			<content:encoded><![CDATA[<p>Occasionally you may have the need to create a file &#8216;fingerprint&#8217; using one of the well known and supported hash programs. The common hash algorithms are:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Md5">MD5 </a>- Dont use if you can avoid it as this is known to have vulnerabilities and should never be used!</li>
<li><a href="http://en.wikipedia.org/wiki/RIPEMD160">RIPEMD160</a> &#8211; This is supported by .Net, but isnt really heavily used. Recommend using SHA256 or SHA512</li>
<li><a href="http://en.wikipedia.org/wiki/Sha1">SHA1</a>- If you can avoid it use SHA256 or SHA512</li>
<li><a href="http://en.wikipedia.org/wiki/Sha1#SHA-2_family">SHA2 </a>Family
<ul>
<li>SHA256</li>
<li>SHA384</li>
<li>SHA512</li>
</ul>
</li>
</ul>
<p>If you haven&#8217;t come across MD5Sum.exe, SHA1Sum.exe, SHA256Sum.exe you can find native Windows ports <a href="http://blog.nfllab.com/archives/152-Win32-native-md5sum,-sha1sum,-sha256sum-etc..html">here</a> (or if you are looking for the more official GNU versions they can be found <a href="ftp://ftp.gnupg.org/gcrypt/binary/">here</a>) . Which if you are just looking for the command line tools that is probably enough. However sometimes you may have the need to do all this work yourselves in C#, if so this is the article that should help guide you!</p>
<p>First of all this is going to be fairly simple as the .Net library supports all of the above hash formats, so all we are really talking about doing is showing you the best way to use the supplied .Net runtimes to perform your hashing. So on to the magic (note to avoid width formatting issues this isnt exactly how I normally format the code!):</p>
<pre class="brush: csharp;">
/// &lt;summary&gt;
/// Performs the SHA1 Hash function on file
/// &lt;/summary&gt;
/// &lt;param name=&quot;filename&quot;&gt;
/// The filename to be hashed.
/// &lt;/param&gt;
/// &lt;returns&gt;
/// SHA1 Hash value associated with the file
/// &lt;/returns&gt;
public static string SHA1HashFile(string filename)
{
   string hashedValue = string.Empty;

   //create our SHA1 provider
   SHA1CryptoServiceProvider hashAlgorithm = new SHA1CryptoServiceProvider();

   //hash the data from the file
   byte[] hashedData = hashAlgorithm.ComputeHash(File.ReadAllBytes(filename));

   //loop through each byte in the returned byte array to convert into printed ASCII
   foreach (byte b in hashedData)
   {
      hashedValue += String.Format(&quot;{0,2:x2}&quot;, b);
   }

   //return the hashed value to the caller
   return hashedValue;
}
</pre>
<p>This does the SHA1 hashing of the supplied file &#8211; and matches the output of GNU version of SHA1Sum.exe. I told you it was simple <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . Dissecting this code should be pretty trivial:</p>
<ol>
<li>Create the SHA1 Service provider (<a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha1cryptoserviceprovider.aspx">System.Security.Cryptography.SHA1CryptoServiceProvider</a>)</li>
<li>Call <a href="http://msdn.microsoft.com/en-us/library/s02tk69a.aspx">ComputeHash</a> passing in a byte array.</li>
<li>Take the results and output it as text. In case it wasnt obvious the results of the hash is a binary blob, hence the need to format it into a string friendly representation.</li>
</ol>
<p>However there are really 2 problems with this code:</p>
<ol>
<li>File.ReadAllBytes &#8211; This returns a byte array of the file &#8211; pretty much as you would expect! The problem is that if this is a very big file, for example a hash for a DVD, the entire file needs to be loaded into memory before it gets hashed. Obviously not the most optimal approach!</li>
<li>This is completely locked into SHA1, you need a new function for any other different hashing function. Not a biggie, but it would be nice to  get some reuse in now and then. Definitely useful if you see the full example where we have to use some fall back processing if an algorithm is not available.</li>
</ol>
<p>Thankfully fixing this is still pretty trivial. To fix issue 1 rather than using the ComputeHash that takes in the byte array, use the one that takes the stream. This avoids the need for having the entire file in memory before the hash process can start. Out of curiosity I looked up the publicly available source code for the function to check it was in fact doing what I thought. Thankfully it is simple and obvious:</p>
<pre class="brush: csharp;">
...
// Default the buffer size to 4K.
byte[] buffer = new byte[4096];
int bytesRead;
do {
   bytesRead = inputStream.Read(buffer, 0, 4096);
   if (bytesRead &gt; 0) {
     HashCore(buffer, 0, bytesRead);
  }
} while (bytesRead &gt; 0);
...
</pre>
<p>So we can see when we use the stream version of <a href="http://msdn.microsoft.com/en-us/library/xa627k19.aspx">HashAlgorithm.ComputeHash Method (Stream)</a> it only will use up a small memory chunk for calculating the hash values. So we are safe from big files from potentially killing the application.</p>
<p>Issue 2 &#8211; The .Net team did a nice job of creating base classes, one of which is <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.hashalgorithm.aspx">HashAlgorithm</a>. This is actually the class that implements the hashing &#8216;interface&#8217;. All hash algorithms must derive from this class. So we can use this to our advantage:</p>
<pre class="brush: csharp;">
/// &lt;summary&gt;
/// Performs a Hash operation on the supplied file.
/// &lt;/summary&gt;
/// &lt;param name=&quot;filename&quot;&gt;
/// The filename to be hashed.
/// &lt;/param&gt;
/// &lt;returns&gt;
/// Selected Hash value associated with the file
/// &lt;/returns&gt;
public static string HashFile(
          string filename
          , HashAlgorithm hashAlgorithm)
{
   if (!File.Exists(filename))
   {
      throw new ArgumentException(filename + &quot; must exist&quot;, &quot;filename&quot;);
   }

   string hashedValue = string.Empty;
   byte[] hashedData = null;

   // Create the stream
   using (FileStream fs = File.Open(filename, FileMode.Open, FileAccess.Read))
   {
      hashedData = hashAlgorithm.ComputeHash(fs);
   }

   //loop through each byte in the returned byte array
   foreach (byte b in hashedData)
   {
      //convert each byte and append
      hashedValue += String.Format(&quot;{0,2:x2}&quot;, b);
   }

   //return the hashed value
   return hashedValue;
}
</pre>
<p>Now we have a generic function to return back a hash value from any supported .Net hash algorithm. To call it you could just do &#8220;HashFile(filename,new SHA1CryptoServiceProvider())&#8221;. Voila! Performance and can trivially support any hashing class the .Net framework implements.</p>
<p>Ok so lets get a little more adventurous now. Attached to this entry is a very simple (aka not fully featured) HashSum source code that allows the same executable to be used to provide all the above hashing! However as a word of caution you need to be a little careful with the more advanced hashing. For example Microsoft supply both &#8220;SHA256CryptoServiceProvider&#8221; and &#8220;SHA256Managed&#8221;. On the surface they look pretty much the same, apart from SHA256CryptoServiceProvider is only available in .Net 3.5 (or higher). However since this uses Operating system cryptographic service providers they may not be available on the platform your program is running on. If that is the case then you will get the PlatformNotSupportedException exception thrown:</p>
<pre class="brush: plain;">
System.PlatformNotSupportedException was unhandled
  Message=&quot;The specified cryptographic algorithm is not supported on this platform.&quot;
  Source=&quot;System.Core&quot;
  StackTrace:
       at System.Security.Cryptography.CapiNative.AcquireCsp(String keyContainer, String providerName, ProviderType providerType, CryptAcquireContextFlags flags, Boolean throwPlatformException)
       at System.Security.Cryptography.CapiHashAlgorithm..ctor(String provider, ProviderType providerType, AlgorithmId algorithm)
       at System.Security.Cryptography.SHA256CryptoServiceProvider..ctor()
       at CSharpHacker.Hash.HashSum.Main(String[] args) in X:\GIT\FileHash\FileSum.cs:line 76
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:
</pre>
<p>Hmmm &#8211; you don&#8217;t read about that little chestnut in the MSDN help! So if you know you are going to only be running this on a Windows 2008, Vista or Windows 7 or later you can just use the &#8220;SHA256CryptoServiceProvider&#8221; version. However if you may have to support systems such as XP (potentially Windows 2003 as well) you will have to use the Managed versions. The safest route would be to provide a graceful fall back mechanism (possibly with a warning) that the CSP version could not be used and using the managed code version instead. This provides the best of both worlds, if the platform supports the CSP version you can use that (which should give you a speed increase) or you use the managed solution.</p>
<pre class="brush: csharp;">
case &quot;SHA256SUM&quot;:
default:
   try
   {
      hashAlgorithm = new SHA256CryptoServiceProvider();
   }
   catch (PlatformNotSupportedException)
   {
      // Fall back to the managed version if the CSP
      // is not supported on this platform.
      hashAlgorithm = new SHA256Managed();
   }
   break;
</pre>
<p>This is a second benefit of using the &#8220;HashAlgorithm&#8221; approach, the underlying code responsible for the generic hashing function is that it doesnt need to know what version (or even algorithm) it is using.</p>
<p>You also have to bear in mind that if you are going to use &#8220;SHA256CryptoServiceProvider&#8221; (or equivalent) you have to be using .Net 3.5 or greater.</p>
<p><a href="/FileSum.zip">Click to download Sample CSharp FileSum project</a></p>
<p>This is a .Net 3.5 project that based off the executable file name it uses that algorithm. So if you rename FileSum.exe to &#8220;SHA512Sum.exe&#8221; it will perform the SHA512 hash on the input file, MD5Sum.exe MD5 hash, etc. If the name is not a recognized name it defaults to using the SHA256 algorithm. This is not designed to be a wholesale replacement for SHA256Sum etc, but more of a guide how to write a fully featured version. So things missing from this include (and are not limited to <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ):</p>
<ul>
<li><span style="text-decoration: line-through;">No support for wildcards (simple enough to add but not there)</span></li>
<li>No support for checking files match the input file (&#8216;-c or &#8211;check&#8217;)</li>
<li>Only binary mode is supported, no support for ASCII/Text mode. No support for &#8216;-t&#8217; or &#8216;&#8211;text&#8217;</li>
<li>No support for standard input processing</li>
</ul>
<p>Hope you found this useful,</p>
<p>Gareth</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 3036px; width: 1px; height: 1px;">
<pre>is not supported</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.csharphacker.com/technicalblog/index.php/2009/07/12/how-to-write-sha256sum-in-c-or-md5sum-sha1sum/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JQuery News</title>
		<link>http://www.csharphacker.com/technicalblog/index.php/2009/07/12/jquery-news/</link>
		<comments>http://www.csharphacker.com/technicalblog/index.php/2009/07/12/jquery-news/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 14:50:45 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.csharphacker.com/technicalblog/?p=352</guid>
		<description><![CDATA[Its seems that JQuery has definitely secured its hold on the JavaScript client toolset. There have been some interesting new extensions that are interesting. JQuery visualize &#8211; Trivially converts an HTML table into a graph using 1 line of code &#8220;$(&#8216;table&#8217;).visualize();&#8221;. Definitely read this one, I&#8217;m not entirely sold on the single line approach &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>Its seems that <a href="http://jquery.com/">JQuery </a>has definitely secured its hold on the JavaScript client toolset. There have been some interesting new extensions that are interesting.</p>
<ul>
<li><a href="http://www.filamentgroup.com/lab/jquery_visualize_plugin_accessible_charts_graphs_from_tables_html5_canvas/">JQuery visualize</a> &#8211; Trivially converts an HTML table into a graph using 1 line of code &#8220;$(&#8216;table&#8217;).visualize();&#8221;. Definitely read this one, I&#8217;m not entirely sold on the single line approach &#8211; but bang for buck its definitely up there. As you would expect it has been tested under IE6, IE7, IE8, Firefox 2, Firefox 3.5, Safari 3 and 4, Opera 9 &#8211; so interoperability is good <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </li>
<li><a href="http://JQueryui.com">JQueryui.com</a> &#8211; jQuery UI provides abstractions for low-level interaction and animation, advanced effects and high-level, themeable widgets, built on top of the jQuery JavaScript Library, that you can use to build highly interactive web applications. The thing I like most with the JavaScript tools is that you can view the <a href="http://jqueryui.com/demos/">demos</a> right in your browser.  JQueryUI has the concept of  <a href="http://jqueryui.com/docs/Theming">Theming </a>which is nice for web developers looking to allow their users to change the look of the applications.</li>
</ul>
<p>Pretty cool stuff,</p>
<p>Gareth</p>
]]></content:encoded>
			<wfw:commentRss>http://www.csharphacker.com/technicalblog/index.php/2009/07/12/jquery-news/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google OS &#8211; What impact to developers??</title>
		<link>http://www.csharphacker.com/technicalblog/index.php/2009/07/08/google-os-what-impact-to-developers/</link>
		<comments>http://www.csharphacker.com/technicalblog/index.php/2009/07/08/google-os-what-impact-to-developers/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 17:47:19 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.csharphacker.com/technicalblog/?p=337</guid>
		<description><![CDATA[As an application developer it makes me wonder where applications are going to end up. Actually I think I know but I'm not sure corporations have really cottoned on to the significant change in technical directions. So let me ask a different question that will circle back around to the impact of Google OS! Everyone is looking into ...]]></description>
			<content:encoded><![CDATA[<p>I have to say that predictably there is a lot of media attention to the <a href="http://googleblog.blogspot.com/2009/07/introducing-google-chrome-os.html">Google OS announcement</a>. Some commentary is below:</p>
<ul>
<li><a href="http://www.texttechnologies.com/2009/07/08/google-chrome-operating-system-microsoft-windows/">Google declares total war on Microsoft</a></li>
<li><a href="http://www.theregister.co.uk/2009/07/08/google_microsoft_phony_chrome_war/">Google&#8217;s vanity OS is Microsoft&#8217;s dream</a></li>
<li><a href="http://chriswoodill.blogspot.com/2009/07/will-google-chrome-os-be-any-different.html">Will Google Chrome OS Be Any Different than LINUX, BEOS, Network Computer, etc.?</a></li>
<li><a href="http://www.networkworld.com/community/node/43355">Google declares total war on Microsoft, but the main battles are years away</a></li>
<li><a href="http://www.intelligententerprise.com/blog/archives/2009/07/googles_chrome.html">Google&#8217;s Chrome Operating System: A Revolution in the Making?</a></li>
</ul>
<p>Actually this is a rare time I disagree with &#8220;TheRegister&#8221;. I think this will have a potentially profound affect on computing as we know it. Years ago we didn&#8217;t have infrastructure to support net computing, but now with the various cloud services and the fact everyone wants connectivity from anywhere  &#8211; now times are different. Obviously only time will tell which is more accurate (no one is ever 100% right <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ).</p>
<p>However as an application developer it makes me wonder where applications are going to end up. Actually I <strong><em>think </em></strong>I know, but I&#8217;m not sure corporations have really cottoned on to the significant change in technical directions. So let me ask a different question that will circle back around to the impact of Google OS! Everyone is looking into supporting low/no footprint client applications (RIA), and we have a varied number of choices:</p>
<ul>
<li>Citrix/XWindows/X11 &#8211; Remote access via terminal sessions</li>
<li>Flash &#8211; The classic RIA  within the browser</li>
<li>SilverLight &#8211; Microsoft RIA platform within the browser</li>
<li>Click-Once-Applications &#8211; .Net applications deployable from the browser</li>
<li>Java FX &#8211; Java RIA platform within the browser</li>
<li>Browser/JavaScript/HTML5 &#8211; the browser!</li>
</ul>
<p>So it would appear the browser is going to be a fairly core piece of architecture that is going to have to exist for a number of years, the question is what is going to become dominate in it? What is your company betting on?</p>
<p>Lets put these choices in a different order of the directions the various supplier companies want <span style="text-decoration: underline;"><strong>us</strong></span> to go in:</p>
<ul>
<li>Sun &#8211; Java FX, multi platform</li>
<li>Microsoft &#8211; Silverlight/.Net click-once, Windows + Mono</li>
<li>Adobe &#8211; Flash, multi platform</li>
<li>Google &#8211; Browser/JavaScript</li>
</ul>
<p>Google is betting on making everything web based and running in the cloud. Now back to the developer question, a couple of years ago there were limited mobile device penetration into the general masses. Blackberries were used by corporate folks to get important emails and general access &#8211; others had pagers! Now a significant growing percentage of people have &#8216;smart phones&#8217; that have &#8216;unlimited&#8217; data plans.  As a developer 5 years ago who would have spoken about supporting Safari as a browser for your application? With the iPhone how many times a day do you think a business person is thinking &#8211; I wish I had this application on my iPhone.</p>
<p>If Google sticks to pure Javascript within the browser they will have coverage EVERYWHERE. Apple cant lock them out through the Apple store, Microsoft cant disable JavaScript support within their browser to cut out Google.  Stability issues cant be attributed to a third party add-in such as JavaFX, Silverlight or Flash which doesn&#8217;t work so well on that specific platform &#8211; the browser is responsible.</p>
<p>Google applications will be globally available to all netbooks, Google OS, Android phones, Windows phones, iPhones and what ever technology platform is next (as long as it has a browser capable of JavaScript). Add to this that HTML is getting smarter with HTML5, things are definitely coming into place for Google.</p>
<p>So back to the question &#8211; <strong>What impact to developers?</strong> My guess is that if you have tried in the past to generate a HTML application and you (or your company) now no longer entertain that idea as it was hard/complicated/problematic &#8211; you will be changing your mind within a couple of years. Naturally there will be ever evolving more helpful tool-sets to further help development, but I think the pure web apps are back in force and will be unstoppably dominant. The question is &#8220;<strong>Are you ready to accept that fact yet?</strong>&#8220;&#8230;</p>
<p>Time will tell <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> , but I&#8217;m betting its going to be nearly pure Web client applications with lots of cloud magic pulling the strings. Google has been quietly moving this way for a while and the Google OS is the beginning of the public face of this change, and as a result this will be a massive change that development shops need to cater for.</p>
<p>Gareth</p>
]]></content:encoded>
			<wfw:commentRss>http://www.csharphacker.com/technicalblog/index.php/2009/07/08/google-os-what-impact-to-developers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WiX v3.0 now available for download</title>
		<link>http://www.csharphacker.com/technicalblog/index.php/2009/07/07/wix-v3-0-now-available-for-download/</link>
		<comments>http://www.csharphacker.com/technicalblog/index.php/2009/07/07/wix-v3-0-now-available-for-download/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 11:39:20 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[HandyTech]]></category>
		<category><![CDATA[Sustainability]]></category>

		<guid isPermaLink="false">http://www.csharphacker.com/technicalblog/?p=332</guid>
		<description><![CDATA[The Wix toolset provides the building blocks for MSI development, aka setup builder. Its been a while watching the various incremental builds coming out for Wix 3, but now we are at the RTM the beginning for 3.0! Over this past weekend it has been marked RTM , the 3.0.5419 build of WiX v3.0 was [...]]]></description>
			<content:encoded><![CDATA[<p>The Wix toolset provides the building blocks for MSI development, aka setup builder.</p>
<p>Its been a while watching the various incremental builds coming out for Wix 3, but now we are at the RTM the beginning for 3.0! Over this past weekend it has been marked RTM , the <a href="http://wix.sourceforge.net/releases/3.0.5419.0/">3.0.5419 build</a> of <a href="http://wix.sourceforge.net/">WiX v3.0</a> was declared the final production build. Read more about the various Wix announcements <a href="http://www.joyofsetup.com/2009/07/04/wix-v3-0-has-been-released/">http://www.joyofsetup.com/2009/07/04/wix-v3-0-has-been-released/</a></p>
<p>The Wix team is now working on 3.5 &#8211; for Visual Studio 2010! Time to upgrade all those earlier versions of 3.0 to the 3.0.5419 build.</p>
<p>For those interested here are some links:</p>
<ul>
<li><a href="http://blogs.msdn.com/astebner/archive/2009/07/06/9820065.aspx">Aaron Stebner&#8217;s WebLog announcement</a> (actually this has the below links in it)</li>
<li><a href="http://wix.sourceforge.net/manual-wix3/main.htm">WiX 3.0 Manual</a> (note this is currently blank when I checked it)</li>
<li>Download the RTM version <a href="http://wix.sourceforge.net/releases/3.0.5419.0/">http://wix.sourceforge.net/releases/3.0.5419.0/</a></li>
</ul>
<p>Many congratulations to the team!</p>
<p>Gareth</p>
]]></content:encoded>
			<wfw:commentRss>http://www.csharphacker.com/technicalblog/index.php/2009/07/07/wix-v3-0-now-available-for-download/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQLite for C# – Part 7 – Building SQLite.Net from source (and netmodules)</title>
		<link>http://www.csharphacker.com/technicalblog/index.php/2009/07/05/sqlite-for-c-part-7%e2%80%93building-sqlite-net-from-source/</link>
		<comments>http://www.csharphacker.com/technicalblog/index.php/2009/07/05/sqlite-for-c-part-7%e2%80%93building-sqlite-net-from-source/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 11:58:59 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SQLite]]></category>

		<guid isPermaLink="false">http://www.csharphacker.com/technicalblog/?p=303</guid>
		<description><![CDATA[One of the key differentiators that SQLite for .Net has is that you have full access to the source code and can compile it. Its interesting in the fact most commercial developers like this option, but rarely use it. Kind of a &#8216;checkbox&#8217; &#8211; &#8220;if I need to can I?&#8221;. This article covers how to [...]]]></description>
			<content:encoded><![CDATA[<p>One of the key differentiators that SQLite for .Net has is that you have full access to the source code and can compile it. Its interesting in the fact most commercial developers like this option, but rarely use it. Kind of a &#8216;checkbox&#8217; &#8211; &#8220;if I need to can I?&#8221;. This article covers how to get the source code from the archive and compile it up. I find this predominately useful if you are isolating a crash, or trying to determine if there is an option you can &#8216;flip&#8217; to get an application to behave the way you want to.</p>
<p>The first thing to do is go and grab the latest source! The source code is currently hosted on SourceForge at: <a href="http://sourceforge.net/projects/sqlite-dotnet2/">http://sourceforge.net/projects/sqlite-dotnet2/</a>. If you go to this page you there are links (or there were at the time of writing!!) to &#8220;Download Now!&#8221; or &#8220;<a href="http://sourceforge.net/projects/sqlite-dotnet2/files/">View all files</a>&#8220;. If you are looking for the source you need to chose &#8220;View all Files&#8221;. From here you should choose the latest source package (currently &#8220;SQLite-1.0.63.0-source.zip&#8221;) and download and unzip to your drive. You should now have the latest and greatest &#8216;stable&#8217; source code, if you need to pick up an in flight fix or need to most up to date you may have to use CVS to download the package. Unfortunately (albeit fortunate for this article) &#8220;SQLite-1.0.63.0-source.zip&#8221; contains an issue where the build didnt completely work straight out of the box for Win32 builds. I contacted the team through the developer forum (<a href="http://sqlite.phxsoftware.com/forums/">http://sqlite.phxsoftware.com/forums/</a>) and the problem was resolved in the latest CVS code patch (Patchset 415). So given this we need to pull it from CVS rather than the prepackaged code. <strong>NOTE: Normally speaking you should only need (and I would recommend only) the packaged code rather than CVS. Only if you want to live on the bleeding edge, or have a real need to get the latest release should you really use the CVS version.</strong> If fact the team doesnt even recommend using the CVS version (<a href="http://sqlite.phxsoftware.com/forums/t/1814.aspx">http://sqlite.phxsoftware.com/forums/t/1814.aspx</a>).</p>
<p>However to complete the full circle and want to go down the CVS route and you are not familiar with CVS you can find out more information <a href="http://en.wikipedia.org/wiki/Concurrent_Versions_System">here</a>. Raw CVS executables for Windows can be found <a href="http://ftp.gnu.org/non-gnu/cvs/binary/stable/x86-woe/">here</a>, but I would recommend if you are going to make a habit out of it you get and use <a href="http://tortoisecvs.sourceforge.net/">TortoiseCVS</a> instead.</p>
<pre class="brush: plain;">
cvs -d:pserver:anonymous@sqlite-dotnet2.cvs.sourceforge.net:/cvsroot/sqlite-dotnet2 login
cvs -z3 -d:pserver:anonymous@sqlite-dotnet2.cvs.sourceforge.net:/cvsroot/sqlite-dotnet2 co -P SQLite.NET
</pre>
<p>[Note if the first line fails create an empty ".cvspass" file and retry it]</p>
<p>Now you should have the latest code straight from the CVS repository, or if you are more sensible <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  the packaged ZIP file covered at the beginning of the article.</p>
<p>Now on to the building! In the top level folder there are 2 interesting/key files:</p>
<ul>
<li>readme.htm &#8211; This details the latest release notes associated with the provider code, and covers the differences between the various historical releases.</li>
<li>SQLite.NET.sln &#8211; This is our well loved and trusted VS2008 solution file!</li>
</ul>
<p>Starting the solution file the solution loads up and with the latest version I&#8217;m using8 projects are loaded:</p>
<ul>
<li>SQLite.Interop</li>
<li>System.Data.SQLite &#8211; Compact</li>
<li>System.Data.SQLite &#8211; Managed Only</li>
<li>System.Data.SQLite &#8211; Netmodule</li>
<li>System.Data.SQLite.Linq</li>
<li>test</li>
<li>testce</li>
<li>testlinq</li>
</ul>
<p>Out of the box you should be able to build the release and debug files. You will also notice slightly different icons associated with the projects &#8220;System.Data.SQLite &#8211; Compact&#8221; &amp; &#8220;testce&#8221;. This is because these builds are targeting a mobile or Compact framework device.  They dont hurt to be there so feel free to ignore them as they wont be used unless you a compact/mobile build type.</p>
<p>Congratulations you should have successfully built the components and can verify your build by running the &#8220;test&#8221; application.</p>
<p><span style="text-decoration: underline;"><strong>Now on to the more technical deep dive of how it works</strong></span></p>
<p>Firstly lets be clear &#8211; this is certainly a non-trivial build process! This is merging C code &amp; .Net code into the same binary DLL using netmodules. More on netmodules can be found at &#8220;<a href="http://msdn.microsoft.com/en-us/library/226t7yxe.aspx">How to: Build a Multifile Assembly</a>&#8220;. Frankly I&#8217;m going to just dive into a little more detail here as this concept is key to the build.</p>
<p>Purely looking at the project in Visual Studio is a little misleading:</p>
<p><img class="aligncenter size-full wp-image-311" title="netmodule" src="http://www.csharphacker.com/technicalblog/wp-content/uploads/2009/07/netmodule.jpg" alt="netmodule" width="668" height="200" /></p>
<p>Hmmm &#8211; a &#8220;Windows Application&#8221; &#8211; really&#8230;. However looking at the &#8220;System.Data.SQLite &#8211; netmodule.csproj&#8221; in a text viewer you see something very different:</p>
<pre class="brush: plain;">

&amp;lt;OutputType&amp;gt;Module&amp;lt;/OutputType&amp;gt;
</pre>
<p>Obviously this is very different than &#8220;&lt;OutputType&gt;Library&lt;/OutputType&gt;&#8221;, &#8220;&lt;OutputType&gt;WinExe&lt;/OutputType&gt;&#8221;, &#8220;&lt;OutputType&gt;Exe&lt;/OutputType&gt;&#8221;. This is the netmodule magic we covered above &#8211; all this is largely hidden from the user if they just look at the VS interface. This magic is then referenced through the SQLite.Interop.vcproj though:</p>
<pre class="brush: plain;">

&amp;lt;Tool
Name=&amp;quot;VCLinkerTool&amp;quot;
AdditionalDependencies=&amp;quot;..\System.Data.SQLite\bin\System.Data.SQLite.netmodule&amp;quot;
OutputFile=&amp;quot;../bin/System.Data.SQLite.DLL&amp;quot;
ModuleDefinitionFile=&amp;quot;src\sqlite3.def&amp;quot;
EmbedManagedResourceFile=&amp;quot;&amp;quot;
DelayLoadDLLs=&amp;quot;advapi32.dll&amp;quot;
RandomizedBaseAddress=&amp;quot;1&amp;quot;
DataExecutionPrevention=&amp;quot;0&amp;quot;
ImportLibrary=&amp;quot;&amp;quot;
TargetMachine=&amp;quot;5&amp;quot;
KeyFile=&amp;quot;..\System.Data.SQLite\System.Data.SQLite.snk&amp;quot;
CLRUnmanagedCodeCheck=&amp;quot;true&amp;quot;
/&amp;gt;
</pre>
<p>The good news about this is that this is just a &#8216;dependency&#8217; and is fully supported in the C/C++ interface in VS2008. A little more can be read about here &#8220;<a href="http://msdn.microsoft.com/en-us/library/k669k83h%28VS.80%29.aspx">.netmodule Files as Linker Input</a>&#8221;</p>
<p>Alright so we now have the background knowledge to understand how this build is actually being used. So now lets look at the what the build sets up for us (the below is really the Win32/x64 build):</p>
<ul>
<li>Debug
<ul>
<li>SQLite.Interop</li>
<li>System.Data.SQLite &#8211; Managed Only</li>
<li>System.Data.SQLite.Linq</li>
<li>test</li>
<li>testlinq</li>
</ul>
</li>
<li>Debug &#8211; Stock
<ul>
<li>System.Data.SQLite &#8211; Managed Only</li>
<li>System.Data.SQLite.Linq</li>
<li>test</li>
</ul>
</li>
<li>Release
<ul>
<li>SQLite.Interop</li>
<li>System.Data.SQLite &#8211; Netmodule</li>
<li>System.Data.SQLite.Linq</li>
<li>test</li>
</ul>
</li>
<li>Release &#8211; Stock
<ul>
<li>System.Data.SQLite &#8211; Managed Only</li>
<li>System.Data.SQLite.Linq</li>
<li>test</li>
</ul>
</li>
</ul>
<p>The project dependencies are:</p>
<ul>
<li>SQLite.InterOp -&gt; System.Data.SQLite &#8211; netmodule</li>
<li>System.Data.SQLite.Linq -&gt; SQLite.InterOp</li>
<li>Test -&gt; SQLite.InterOp</li>
</ul>
<p>You can see that only the &#8220;Release&#8221; build doesn&#8217;t include the &#8220;System.Data.SQLite &#8211; Managed Only&#8221; version. Any build other than this one generates a build that requires both &#8220;System.Data.SQLite&#8221; and &#8220;SQLite.Interop.DLL&#8221;. The &#8220;Managed Only&#8221; isn&#8217;t a pure managed only version of SQLite, it still uses the native SQL C runtime code &#8211; but it makes the call out to the Interop dll. The &#8216;netmodule&#8217; version is used to embed in the ADO.NET C# classes into the &#8216;System.Data.SQLite&#8217; DLL, all other builds of &#8216;System.Data.SQLite&#8217; just reference the interop DLL.</p>
<p><strong>Release Build</strong></p>
<p>As mentioned before, in the release build SQLite.Interop is where all the magic happens in this build! This is the one that outputs bin\System.Data.SQLite.DLL (note in all other builds this generates &#8216;SQLite.Interop.dll&#8217; or in the stock case &#8216;sqlite3.dll&#8217;). However since this is really compiling the standard C SQLite code there is a little more magic going on here. This project has the linker dependency on &#8220;..\System.Data.SQLite\bin\System.Data.SQLite.netmodule&#8221;. This is how we get the C# ADO.NET provider injected into the System.Data.SQLite.DLL through the netmodules. However this process has the side effect of not being able to debug into the provider <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> . So for source code debugging use the debug build that references &#8220;Managed Only&#8221; rather than the netmodule.</p>
<p><strong>Debug Build</strong></p>
<p>From now on it is fairly standard, although I have seen an odd quirk is that if you attempt to debug into the regular &#8220;Debug Build&#8221; an error is through regarding the &#8220;&#8216;OutputType&#8217; failed&#8221;, if you use the &#8220;Debug &#8211; Stock&#8221; build this goes away as the &#8216;netmodule&#8217; is not included in the build.</p>
<p>Happy compiling and debugging!</p>
<p><strong>Related Links:</strong></p>
<ul>
<li><a href="/technicalblog/index.php/2009/06/16/sqlite-for-c-part-1-am-i-allowed-to-use-it/">SQLite for C# &#8211; Part 1 &#8211; Am I allowed to use it?</a></li>
<li><a href="/technicalblog/index.php/2009/06/17/sqlite-for-c-part-2-how-do-i-setup-a-sqlite-db-without-coding/">SQLite for C# – Part 2 – How do I setup a SQLite DB (without coding)</a></li>
<li><a href="/technicalblog/index.php/2009/06/28/sqlite-for-c-%e2%80%93-part-3-%e2%80%93-my-first-c-app-using-sqlite-aka-hello-world/">SQLite for C# – Part 3 – My first C# app using SQLite aka Hello World</a></li>
<li><a href="/technicalblog/index.php/2009/06/30/sqlite-for-c-%e2%80%93-part-4-%e2%80%93-so-how-does-sqlite-stack-up-against-other-dbs/">SQLite for C# – Part 4 – So how does SQLite stack up against other DB’s?</a></li>
<li><a href="/technicalblog/index.php/2009/07/01/sqlite-for-c-%e2%80%93-part-5-%e2%80%93-sqlite-features-or-quirks/">SQLite for C# – Part 5 – SQLite ‘features’, or ‘quirks’</a></li>
<li><a href="/technicalblog/index.php/2009/07/02/sqlite-for-c-%e2%80%93-part-6-%e2%80%93-sqlite-connection-string-definitions/">SQLite for C# – Part 6 – SQLite Connection String Definitions</a></li>
<li>SQLite for C# – Part 7 – Building SQLite.Net from source</li>
<li><a href="/technicalblog/index.php/2009/09/19/sqliteforcsharppart8loadingcsvpipeintosqliteviacommandline/">SQLite for C# – Part 8 – Loading CSV/Pipe into SQLite via command line</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.csharphacker.com/technicalblog/index.php/2009/07/05/sqlite-for-c-part-7%e2%80%93building-sqlite-net-from-source/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Morning news 2009-07-05</title>
		<link>http://www.csharphacker.com/technicalblog/index.php/2009/07/05/morning-news-2009-07-05/</link>
		<comments>http://www.csharphacker.com/technicalblog/index.php/2009/07/05/morning-news-2009-07-05/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 10:17:59 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.csharphacker.com/technicalblog/?p=306</guid>
		<description><![CDATA[Its amazing how light the news has been this week.. Its almost like there is a holiday going on somewhere in the world . This is going to be a light news one as well: Mono on PS3 making progress Canonical offers tech support for clouds &#8211; Ubuntu + Eucalyptus = homegrown EC2 Handy listing: [...]]]></description>
			<content:encoded><![CDATA[<p>Its amazing how light the news has been this week.. Its almost like there is a holiday going on somewhere in the world <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . This is going to be a light news one as well:</p>
<ul>
<li><a href="http://tirania.org/blog/archive/2009/Jul-03.html">Mono on PS3 making progress</a></li>
<li><a href="http://www.channelregister.co.uk/2009/07/01/ubuntu_cloud_support/">Canonical offers tech support for clouds &#8211; Ubuntu + Eucalyptus = homegrown EC2</a></li>
<li>Handy listing: <a href="http://msdn.microsoft.com/en-us/magazine/cc501040.aspx">MSDN Magazine: CLR Inside Out</a>
<ul>
<li>All the CLR news from MSDN magazine. Definitely good stuff here.</li>
<li><a href="http://msdn.microsoft.com/en-us/magazine/dd882521.aspx">Memory Usage Auditing For .NET Applications</a> &#8211; Who doesnt need more help monitoring their .Net applications!</li>
</ul>
</li>
<li><a href="http://blogs.msdn.com/psssql/archive/2009/07/01/when-in-doubt-reboot.aspx">When in doubt reboot</a>
<ul>
<li>I don&#8217;t feel so bad now when I read a Microsoft engineer admits sometimes this draconian measure is sometimes needed. I would also read this is you have ever faced &#8220;Kerberos&#8221; &#8216;opportunities&#8217;.  It also mentions how they purged all of the Kerberos Tickets using KerbTray which is part of the Windows Resource Kit.</li>
</ul>
</li>
<li><a href="http://code.google.com/p/gchart/">GChart 2.5 released</a> &#8211; Uses GWT for those using that.</li>
</ul>
<p>Gareth</p>
]]></content:encoded>
			<wfw:commentRss>http://www.csharphacker.com/technicalblog/index.php/2009/07/05/morning-news-2009-07-05/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQLite for C# – Part 6 – SQLite Connection String Definitions</title>
		<link>http://www.csharphacker.com/technicalblog/index.php/2009/07/02/sqlite-for-c-%e2%80%93-part-6-%e2%80%93-sqlite-connection-string-definitions/</link>
		<comments>http://www.csharphacker.com/technicalblog/index.php/2009/07/02/sqlite-for-c-%e2%80%93-part-6-%e2%80%93-sqlite-connection-string-definitions/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 06:40:06 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SQLite]]></category>

		<guid isPermaLink="false">http://www.csharphacker.com/technicalblog/?p=293</guid>
		<description><![CDATA[Alright &#8211; so we are now ready to get started in earnest. The first thing we need to do when connecting to a database is setup the connection string. This article covers the various connection string parameters available for the .Net version for SQLite. Most Simple &#8211; Data Source Format: &#8220;Data Source=[DBFileName]&#8221; Example: @&#8221;Data Source=C:\CSharpHackerDemo.db3&#8243; [...]]]></description>
			<content:encoded><![CDATA[<p>Alright &#8211; so we are now ready to get started in earnest. The first thing we need to do when connecting to a database is setup the connection string. This article covers the various connection string parameters available for the .Net version for SQLite.</p>
<p><strong><span style="text-decoration: underline;">Most Simple &#8211; Data Source</span></strong><br />
Format: &#8220;Data Source=[DBFileName]&#8221;<br />
Example: @&#8221;Data Source=C:\CSharpHackerDemo.db3&#8243;</p>
<p>This connection string will create the database if it doesnt already exist without notifying you. For some utility functions this may be exactly what is desired, in some cases you want to know your DB doesnt exist!</p>
<p>If you want to programatically create the file intentionally, presumably if  &#8220;!File.Exists()&#8221; you can do:</p>
<pre class="brush: csharp;">
SQLiteConnection.CreateFile(@&amp;quot;C:\CSharpHackerDemo.db3&amp;quot;);
</pre>
<p><strong><span style="text-decoration: underline;">Only Open if it exists &#8211; FailIfMissing</span></strong><br />
Format: &#8220;Data Source=[DBFileName];FailIfMissing=True;&#8221;<br />
Example: @&#8221;Data Source=C:\CSharpHackerDemo.db3;FailIfMissing=True;&#8221;</p>
<p>With this connection string if the DB file is not present the open will fail.</p>
<p><strong><span style="text-decoration: underline;">Secure/Encrypt the DB &#8211; Password</span></strong><br />
Format: &#8220;Data Source=[DBFileName];Password=[123456789];&#8221;<br />
Example: @&#8221;Data Source=C:\CSharpHackerDemo.db3;Password=[123456789];&#8221;</p>
<p>With this connection string if the DB file will be created or opened using the password as the encryption key.</p>
<p>Other options:</p>
<ul>
<li><strong>ReadOnly</strong> &#8211; When enabled, the database will be opened for read-only access and writing will be disabled. Default False.</li>
<li><strong>CacheSize</strong> &#8211; Sets the cache size for the connection. Default value is 2000 bytes. Under the covers this calls &#8220;PRAGMA cache_size={0}&#8221;.</li>
<li><strong>PageSize</strong> &#8211; Sets the database page size. Under the covers this calls &#8220;PRAGMA page_size={0}&#8221;. Default is 1024 bytes.</li>
<li><strong>MaxPageCount</strong> &#8211; Sets the maximum number of pages the database may hold. Default is 0 which is unrestricted. Under the covers this calls &#8220;PRAGMA max_page_count={0}&#8221;.</li>
<li><strong>DateTimeFormat </strong>- Sets the datetime format for the connection. Default is ISO8601
<ul>
<li><strong>Ticks </strong>- Using ticks is not recommended and is not well supported with LINQ.</li>
<li><strong>ISO8601 </strong>- Default format for this provider.</li>
<li><strong>JulianDay </strong>- JulianDay format, which is what SQLite uses internally</li>
</ul>
</li>
<li><strong>JournalMode </strong>- Determines how SQLite handles the transaction journal file.  Under the covers this calls &#8220;PRAGMA journal_mode={0}&#8221;. Default &#8220;Delete&#8221;
<ul>
<li><strong>Delete </strong>- default mode, this causes SQLite to create and destroy the journal file as-needed.</li>
<li><strong>Persist </strong>- When this is set, SQLite will keep the journal file even after a transaction has completed.  It&#8217;s contents will be erased, and the journal re-used as often as needed.  If it is deleted, it will be recreated the next time it is needed.</li>
<li><strong>Off </strong>- This option disables the rollback journal entirely.  Interrupted transactions or a program crash can cause database corruption in this mode!</li>
</ul>
</li>
<li><strong>DefaultIsolationLevel </strong>- Sets the default isolation level for transactions on the connection. Default &#8220;Serializable&#8221;. Note this is a standard .Net &#8220;System.Data.IsolationLevel&#8221; type. Do not even try to change this <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . Only &#8220;Serializable&#8221; and &#8220;ReadCommitted&#8221; can be used, all others will throw a &#8220;NotSupportedException&#8221;. However for completeness the full list and meanings are outlined below:
<ul>
<li><strong>Serializable </strong>- A range lock is placed on the DataSet, preventing other users from updating or inserting rows into the dataset until the transaction is complete.</li>
<li><strong>ReadUncommitted &#8211; </strong>A dirty read is possible, meaning that no shared locks are issued and no exclusive locks are honored.</li>
<li><strong>ReadCommitted </strong>- Shared locks are held while the data is being read to avoid dirty reads, but the data can be changed before the end of the transaction, resulting in non-repeatable reads or phantom data.</li>
<li><strong>RepeatableRead </strong>- Locks are placed on all data that is used in a query, preventing other users from updating the data. Prevents non-repeatable reads but phantom rows are still possible.</li>
<li><strong>Snapshot </strong>- Reduces blocking by storing a version of data that one application can read while another is modifying the same data. Indicates that from one transaction you cannot see changes made in other transactions, even if you requery.</li>
<li><strong>Chaos </strong>- The pending changes from more highly isolated transactions cannot be overwritten.</li>
<li><strong>Unspecified </strong>- A different isolation level than the one specified is being used, but the level cannot be determined.</li>
</ul>
</li>
<li><strong>Version</strong> &#8211; Sets the default version of the SQLite engine to instantiate.  Currently the only valid value is 3, indicating version 3 of the SQLite library.</li>
<li><strong>Synchronous</strong> &#8211; Sets the synchronization mode (file flushing) of the connection string.  Default is &#8220;Normal&#8221;.  Under the covers this calls &#8220;PRAGMA synchronous={0}&#8221;. Supported values are:
<ul>
<li>Normal &#8211; Normal file flushing at critical sections of the code</li>
<li>Full &#8211; Full file flushing after every write operation</li>
<li>Off &#8211; Use the default operating system&#8217;s file flushing, SQLite does not explicitly flush the file buffers after writing</li>
</ul>
</li>
<li><strong>UseUTF16Encoding</strong> &#8211; Boolean indicator setting the encoding for the connection.  The default is &#8220;False&#8221; which indicates UTF-8 encoding.</li>
<li><strong>Pooling</strong> &#8211; Sets whether or not to use connection pooling.  The default is &#8220;False&#8221;</li>
<li><strong>BinaryGUID </strong>- Sets to or not to store GUID&#8217;s in binary format.  The default is True which saves space in the database.</li>
<li><span style="text-decoration: line-through;"><em>Deprecated</em></span> <strong>Uri</strong> &#8211; depreciated call to the data source property.</li>
<li><strong>DefaultTimeout</strong> &#8211; sets the default command timeout for newly-created commands.  This is especially useful for commands used internally such as inside a SQLiteTransaction, where setting the timeout is not possible. Time is in seconds, the default is 30 seconds.</li>
<li><strong>Enlist</strong> &#8211; Determines whether or not the connection will automatically participate in the current distributed transaction (if one exists). Default is True.</li>
<li><strong>LegacyFormat</strong> &#8211; If enabled, uses the legacy 3.xx format for maximum compatibility, but results in larger database sizes. Default is False. Under the covers this calls &#8220;PRAGMA legacy_file_format={0}&#8221;.</li>
</ul>
<p>So this is the connection string options available on the latest release. The interesting part is how I found this &#8211; in the source code (so at least now you dont need to do that part). However the next blog will be how to build the provider to help you diagnose and understand any issues you come across.</p>
<p><strong>Series Links:</strong></p>
<ul>
<li><a href="/technicalblog/index.php/2009/06/16/sqlite-for-c-part-1-am-i-allowed-to-use-it/">SQLite for C# &#8211; Part 1 &#8211; Am I allowed to use it?</a></li>
<li><a href="/technicalblog/index.php/2009/06/17/sqlite-for-c-part-2-how-do-i-setup-a-sqlite-db-without-coding/">SQLite for C# – Part 2 – How do I setup a SQLite DB (without coding)</a></li>
<li><a href="/technicalblog/index.php/2009/06/28/sqlite-for-c-%e2%80%93-part-3-%e2%80%93-my-first-c-app-using-sqlite-aka-hello-world/">SQLite for C# – Part 3 – My first C# app using SQLite aka Hello World</a></li>
<li><a href="/technicalblog/index.php/2009/06/30/sqlite-for-c-%e2%80%93-part-4-%e2%80%93-so-how-does-sqlite-stack-up-against-other-dbs/">SQLite for C# – Part 4 – So how does SQLite stack up against other DB’s?</a></li>
<li><a href="/technicalblog/index.php/2009/07/01/sqlite-for-c-%e2%80%93-part-5-%e2%80%93-sqlite-features-or-quirks/">SQLite for C# – Part 5 – SQLite ‘features’, or ‘quirks’</a></li>
<li>SQLite for C# – Part 6 – SQLite Connection String Definitions</li>
<li><a href="/technicalblog/index.php/2009/07/05/sqlite-for-c-part-7%e2%80%93building-sqlite-net-from-source/">SQLite for C# – Part 7 – Building SQLite.Net from source</a></li>
<li><a href="/technicalblog/index.php/2009/09/19/sqliteforcsharppart8loadingcsvpipeintosqliteviacommandline/">SQLite for C# – Part 8 – Loading CSV/Pipe into SQLite via command line</a></li>
</ul>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px;">
<pre><span><span style="font-size: x-small;"><span style="color: #008080;"> SQLiteConnection</span>.CreateFile(<span style="color: #800000;">"c:\\mydatabasefile.db3"</span>);</span></span><span><span style="font-size: x-small;"><span style="color: #008080;"> SQLiteConnection</span>.CreateFile(<span style="color: #800000;">"c:\\mydatabasefile.db3"</span>);</span></span></pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.csharphacker.com/technicalblog/index.php/2009/07/02/sqlite-for-c-%e2%80%93-part-6-%e2%80%93-sqlite-connection-string-definitions/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SQLite for C# – Part 5 – SQLite &#8216;features&#8217;, or &#8216;quirks&#8217;</title>
		<link>http://www.csharphacker.com/technicalblog/index.php/2009/07/01/sqlite-for-c-%e2%80%93-part-5-%e2%80%93-sqlite-features-or-quirks/</link>
		<comments>http://www.csharphacker.com/technicalblog/index.php/2009/07/01/sqlite-for-c-%e2%80%93-part-5-%e2%80%93-sqlite-features-or-quirks/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 05:21:09 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SQLite]]></category>

		<guid isPermaLink="false">http://www.csharphacker.com/technicalblog/?p=281</guid>
		<description><![CDATA[So before I start I dont want to get into any religious debates on if this is a feature,  a quirk or something else. The goal here is to identify areas where SQLite behaves differently than either other DB systems or just in an unexpected/unanticipated way. So starting with the biggies: 1) Limited Database enforced [...]]]></description>
			<content:encoded><![CDATA[<p>So before I start I dont want to get into any religious debates on if this is a feature,  a quirk or something else. The goal here is to identify areas where SQLite behaves differently than either other DB systems or just in an unexpected/unanticipated way.</p>
<p>So starting with the biggies:</p>
<p><strong>1) Limited Database enforced Type Safety:</strong></p>
<pre class="brush: sql;">
CREATE TABLE  IF NOT EXISTS Book
(
BookISBN     varchar(14) primary key
,Name         varchar(200)
,PublisherId    int
);

INSERT INTO BOOK(BookISBN,Name)
VALUES(
     &amp;quot;ReallyLongValueThatShouldCauseAProblem&amp;quot;
    , &amp;quot;CSharpHacker SQLite Manual&amp;quot;);
</pre>
<p>Most DBs honor the restrictions of the character lengths. SQLite will record the information you submit to it &#8211; even it is technically breaks your DDL definitions. More about this can be read about it <a href="http://www.sqlite.org/datatype3.html">Datatypes In SQLite Version 3</a>. What should specifically be called out is:</p>
<blockquote><p>Any column in a version 3 database, except an INTEGER PRIMARY KEY column, may be used to store any type of value.</p></blockquote>
<p>So a more outlandish example would be:</p>
<pre class="brush: sql;">
DROP TABLE IF EXISTS Issue;
CREATE TABLE  IF NOT EXISTS Issue
(
 IssueId 	int
,Description	varchar(200)
);
INSERT INTO Issue(IssueId,Description)
VALUES(
     &amp;quot;ReallyLongTextValueThatShouldCauseAProblem&amp;quot;
     , &amp;quot;CSharpHacker SQLite Manual&amp;quot;);
SELECT * from Issue;
</pre>
<p>If you run the above you get &#8220;ReallyLongTextValueThatShouldCauseAProblem|CSharpHacker SQLite Manual&#8221;, with no errors!<br />
Is that the sound of DBA&#8217;s running away screaming in horror&#8230;? Believe it or not this was intentional, and &#8216;sometimes&#8217; sensible <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . I&#8217;ll cover a little more on that later, but lets go full circle on this.</p>
<p>Underneath the covers there is a 64 bit row identifier attached to every row, but if you want to use your own you can override that to use your own values. If you do this then this column categorically has to be an INTEGER value. So looking at the SQL below you can see we have now changed the type from &#8216;int&#8217; to &#8216;INTEGER PRIMARY KEY&#8217;. This now enforces you have a value that is an integer for this one column, and the below fails with a &#8220;SQL error near line xx: datatype mismatch&#8221;.</p>
<pre class="brush: sql;">
DROP TABLE IF EXISTS Issue2;
CREATE TABLE  IF NOT EXISTS Issue2
(
 IssueId 	INTEGER Primary key
,Description	varchar(200)
);
INSERT INTO Issue2(IssueId,Description)
VALUES(
     &amp;quot;ReallyLongTextValueThatShouldCauseAProblem&amp;quot;
    , &amp;quot;CSharpHacker SQLite Manual&amp;quot;);
SELECT * from Issue2;
</pre>
<p>So one final warning &#8220;INTEGER PRIMARY KEY&#8221; is the same as &#8220;integer primary key&#8221;, but not &#8220;int primary key&#8221;. If you are wanting to override the internal 64 bit row identifier you have to use &#8220;integer&#8221; and not &#8220;int&#8221;, &#8220;bigint&#8221;, &#8220;short integer&#8221;. Thats an easy one to miss! Final quirk is that the &#8220;INTEGER PRIMARY KEY&#8221; needs to be exactly that or &#8220;INTEGER PRIMARY KEY ASC&#8221; (case insensitive), but &#8220;INTEGER PRIMARY KEY DESC&#8221; will not use the internal ID.</p>
<p><strong>2. Only one process can write to the DB at the same time</strong></p>
<p>The locking in SQLite is not fine grained! If anyone is writing to the DB it locks everyone and everything else out of the DB. All readers and writers are blocked until the pending write is done. So if you are expecting a lot of concurrent writes to the database that may need to be interleaved with some reads from other threads/processes you may experience some blocking. In reality it shouldnt matter too much as the writes are normally speedy. It should also be noted that in SQLite v2 there was a possibility of writer starvation where so many reads are going on the writer was never able to lock the file to perform the write &#8211; this has been addressed in SQLite V3.</p>
<p><strong>3. Limited support for ALTER TABLE</strong></p>
<p>Now I bet this has driven off the DBA&#8217;s now! Because of its heritage SQLite team hasn&#8217;t ever needed to support the more complex data migrations supported by other database products. You can use to add a column to the end of a table or to change the name of a table. However if you want to make more complex changes in the structure of a table, you have to recreate a new table and then copy the contents of your old table into the new one. </p>
<p><strong>4. Foreign Keys are &#8216;recorded&#8217; but not enforced</strong></p>
<p>Technically the same thing can be achieved using the &#8216;Triggers&#8217;, but you need to be aware that these are &#8216;soft RI&#8217; keys and are not enforced by the database engine.</p>
<p><strong>5. Support for UPSERT via &#8220;REPLACE&#8221; or &#8220;INSERT OR REPLACE&#8221;</strong></p>
<p>For MySQL users they are familiar with REPLACE, SQLite has aliased REPLACE to its native &#8220;INSERT OR REPLACE&#8217;. </p>
<p>So if you are still reading that is good! This is definitely the scary page that drives a few DBA&#8217;s into fits, but its sensible to know what you are using and its behaviors before it surprises you.</p>
<p><strong>Related Links:</strong></p>
<ul>
<li><a href="/technicalblog/index.php/2009/06/16/sqlite-for-c-part-1-am-i-allowed-to-use-it/">SQLite for C# &#8211; Part 1 &#8211; Am I allowed to use it?</a></li>
<li><a href="/technicalblog/index.php/2009/06/17/sqlite-for-c-part-2-how-do-i-setup-a-sqlite-db-without-coding/">SQLite for C# – Part 2 – How do I setup a SQLite DB (without coding)</a></li>
<li><a href="/technicalblog/index.php/2009/06/28/sqlite-for-c-%e2%80%93-part-3-%e2%80%93-my-first-c-app-using-sqlite-aka-hello-world/">SQLite for C# – Part 3 – My first C# app using SQLite aka Hello World</a></li>
<li><a href="/technicalblog/index.php/2009/06/30/sqlite-for-c-%e2%80%93-part-4-%e2%80%93-so-how-does-sqlite-stack-up-against-other-dbs/">SQLite for C# – Part 4 – So how does SQLite stack up against other DB’s?</a></li>
<li>SQLite for C# – Part 5 – SQLite ‘features’, or ‘quirks’</li>
<li><a href="/technicalblog/index.php/2009/07/02/sqlite-for-c-%e2%80%93-part-6-%e2%80%93-sqlite-connection-string-definitions/">SQLite for C# – Part 6 – SQLite Connection String Definitions</a></li>
<li><a href="/technicalblog/index.php/2009/07/05/sqlite-for-c-part-7%e2%80%93building-sqlite-net-from-source/">SQLite for C# – Part 7 – Building SQLite.Net from source</a></li>
<li><a href="/technicalblog/index.php/2009/09/19/sqliteforcsharppart8loadingcsvpipeintosqliteviacommandline/">SQLite for C# – Part 8 – Loading CSV/Pipe into SQLite via command line</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.csharphacker.com/technicalblog/index.php/2009/07/01/sqlite-for-c-%e2%80%93-part-5-%e2%80%93-sqlite-features-or-quirks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQLite for C# – Part 4 – So how does SQLite stack up against other DB&#8217;s?</title>
		<link>http://www.csharphacker.com/technicalblog/index.php/2009/06/30/sqlite-for-c-%e2%80%93-part-4-%e2%80%93-so-how-does-sqlite-stack-up-against-other-dbs/</link>
		<comments>http://www.csharphacker.com/technicalblog/index.php/2009/06/30/sqlite-for-c-%e2%80%93-part-4-%e2%80%93-so-how-does-sqlite-stack-up-against-other-dbs/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 06:01:59 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SQLite]]></category>

		<guid isPermaLink="false">http://www.csharphacker.com/technicalblog/?p=274</guid>
		<description><![CDATA[Well I would actually advocate the question/title of this topic is misplaced. This is really the question I would have asked probably 4 months ago, and in all likelihood dismissed SQLite after hearing the answers! So bear with me, its worth the read! The key question that really should be asked is not how it [...]]]></description>
			<content:encoded><![CDATA[<p>Well I would actually advocate the question/title of this topic is misplaced. This is really the question I would have asked probably 4 months ago, and in all likelihood dismissed SQLite after hearing the answers! So bear with me, its worth the read! The key question that really should be asked is <span style="text-decoration: underline;"><strong>not</strong></span> how it stacks up, but what are its strengths and in what circumstances should I use it. In essence what problems is SQLite designed to solve rather than academic bullet point comparisons.</p>
<p>However back to the question &#8211; How does it stack up?</p>
<table style="height: 248px;" border="1" width="415">
<tbody>
<tr>
<th>Question</th>
<th>SQLite</th>
<th>SQL Server</th>
<th>SQL CE</th>
</tr>
<tr>
<td>Support multiple clients</td>
<td>Y (not in client server mode, but shared file access)</td>
<td>Y</td>
<td>N</td>
</tr>
<tr>
<td>Requires Server process</td>
<td>N</td>
<td>Y</td>
<td>N</td>
</tr>
<tr>
<td>Support views</td>
<td>Y</td>
<td>Y</td>
<td>N</td>
</tr>
<tr>
<td>Support Stored Procedures</td>
<td>N</td>
<td>Y</td>
<td>N</td>
</tr>
<tr>
<td>Trigger Support</td>
<td>Y</td>
<td>Y</td>
<td>N</td>
</tr>
<tr>
<td>Foreign Key Constraints</td>
<td>N &#8211; Can be achieved via triggers</td>
<td>Y</td>
<td>Y</td>
</tr>
<tr>
<td>Multiple processes read/write to DB</td>
<td>Y</td>
<td>Y</td>
<td>N</td>
</tr>
<tr>
<td>Natively Support Microsoft Replication</td>
<td>N</td>
<td>Y</td>
<td>Y</td>
</tr>
<tr>
<td>Max DB size</td>
<td>Big (max pages=1073741823 * max page size=32768)</td>
<td>Too big to matter!</td>
<td>4 Gb</td>
</tr>
<tr>
<td>Max CPUs</td>
<td>All</td>
<td>All</td>
<td>1</td>
</tr>
<tr>
<td>Max CPUs</td>
<td>All</td>
<td>All</td>
<td>1</td>
</tr>
<tr>
<td>#Files to distribute</td>
<td>1</td>
<td>100&#8242;s</td>
<td>2-7</td>
</tr>
<tr>
<td>Run Windows Mobile Devices</td>
<td>Y</td>
<td>N</td>
<td>Y</td>
</tr>
<tr>
<td>Run Non Windows Mobile Devices</td>
<td>Y</td>
<td>N</td>
<td>N</td>
</tr>
<tr>
<td>Support in MONO</td>
<td>Y</td>
<td>N</td>
<td>N</td>
</tr>
</tbody>
</table>
<p>As you can see SQL Server definitely has the most features, in fact as far as features go its a slam dunk. However often feature count just isn&#8217;t everything. The major drawback for SQL Server is that it requires a Server process to run, and that then means maintenance, probably a DBA and all of a sudden things have got complicated (and expensive)! So we come back to the question &#8220;What are we looking to do with the database?&#8221;. If the answer is heavy duty processing that requires stored procedures, cubes and large amount of concurrent remote access by users &#8211; SQL Server is definitely your answer. However I have to think that you are reading this because SQL Server is too heavy weight for your needs. So on to the other candidates.</p>
<p>SQL CE is a Microsoft database that started in the mobile space and moved up to the PC platform. Overall is has reasonable features but is known to be slower and heavier than SQLite. It definitely has some strengths in the SQL Server ==&gt; SQL CE replication, but outside of that its largely even or less featured that SQLite. If you are looking for replication definitely checkout SQL CE, but I would also say the <a href="http://msdn.microsoft.com/en-us/sync/bb821992.aspx">Microsoft Synch</a> framework is evolving and we may see a native SQLite provider (or determine that the ADO.NET is sufficient) in this area.</p>
<p>SQLite is a lightweight add-on to C# (System.Data.SQLite.DLL ~ 850Kb). You may note this is heavier than the often referenced SQLite runtimes take &#8220;200Kb&#8221;, but in this 850Kb (457Kb Zipped) is the SQL DLL, ADO.NET SQLite provider and the magic glue to bring these two worlds together. If you are using .Net you can assume you have to assume your package size will go up by 457Kb, and the runtime size on disk will be ~850Kb. Performance of SQLite ranks it above SQL CE for insert tests, and it has a lower file size &#8211; and the database can be assessed on a massive number of operating systems!</p>
<p>Before you jump whole heartedly on the SQLite bandwagon, it is only fair to also point out SQLite has some quirks (SQLite folks call these &#8216;features&#8217; &#8211; I&#8217;m not going to argue, but its approach is different in a couple of cases). I&#8217;m going to cover these in the next blog entry &#8220;Part 5&#8243;. These are things that you definitely need to be aware of rather than discover!</p>
<p>The key question that the article should be asking is &#8220;What type of application features benefits from SQLite?&#8221;. The best way I can describe SQLite is that is is an &#8220;Application Data Store&#8221; that you then have ANSI-92 SQL access to. This removes the needs of rolling your own indexing into files, creating convoluted file system &#8216;databases&#8217; etc. If you can wrap your head around how you can use SQLite to your advantage I think you will be pleasantly surprised.</p>
<p><strong>Related Links:</strong></p>
<ul>
<li><a href="/technicalblog/index.php/2009/06/16/sqlite-for-c-part-1-am-i-allowed-to-use-it/">SQLite for C# &#8211; Part 1 &#8211; Am I allowed to use it?</a></li>
<li><a href="/technicalblog/index.php/2009/06/17/sqlite-for-c-part-2-how-do-i-setup-a-sqlite-db-without-coding/">SQLite for C# – Part 2 – How do I setup a SQLite DB (without coding)</a></li>
<li><a href="/technicalblog/index.php/2009/06/28/sqlite-for-c-%e2%80%93-part-3-%e2%80%93-my-first-c-app-using-sqlite-aka-hello-world/">SQLite for C# – Part 3 – My first C# app using SQLite aka Hello World</a></li>
<li>SQLite for C# – Part 4 – So how does SQLite stack up against other DB’s?</li>
<li><a href="/technicalblog/index.php/2009/07/01/sqlite-for-c-%e2%80%93-part-5-%e2%80%93-sqlite-features-or-quirks/">SQLite for C# – Part 5 – SQLite ‘features’, or ‘quirks’</a></li>
<li><a href="/technicalblog/index.php/2009/07/02/sqlite-for-c-%e2%80%93-part-6-%e2%80%93-sqlite-connection-string-definitions/">SQLite for C# – Part 6 – SQLite Connection String Definitions</a></li>
<li><a href="/technicalblog/index.php/2009/07/05/sqlite-for-c-part-7%e2%80%93building-sqlite-net-from-source/">SQLite for C# – Part 7 – Building SQLite.Net from source</a></li>
<li><a href="/technicalblog/index.php/2009/09/19/sqliteforcsharppart8loadingcsvpipeintosqliteviacommandline/">SQLite for C# – Part 8 – Loading CSV/Pipe into SQLite via command line</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.csharphacker.com/technicalblog/index.php/2009/06/30/sqlite-for-c-%e2%80%93-part-4-%e2%80%93-so-how-does-sqlite-stack-up-against-other-dbs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mono in the news again! 2.4.2 released with MVC support, and Stallman against Mono&#8230;</title>
		<link>http://www.csharphacker.com/technicalblog/index.php/2009/06/29/mono-in-the-news-again-2-4-2-released-with-mvc-support-and-stallman-against-mono/</link>
		<comments>http://www.csharphacker.com/technicalblog/index.php/2009/06/29/mono-in-the-news-again-2-4-2-released-with-mvc-support-and-stallman-against-mono/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 00:30:57 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.csharphacker.com/technicalblog/?p=270</guid>
		<description><![CDATA[Firstly and most importantly Mono 2.4.2 release is now available. Major highlights include: In addition to bug fixes, this release includes the following major changes from 2.4.0: We now ship Microsoft&#8217;s ASP.NET MVC (http://www.asp.net/mvc) stack and ASP.NET MVC applications can run with Mono. xbuild has been updated Removed non-free amqp0-8.xml documentation. More detailed information can [...]]]></description>
			<content:encoded><![CDATA[<p>Firstly and most importantly <a href="http://www.mono-project.com/news/archive/2009/Jun-29.html">Mono 2.4.2</a> release is now available. Major highlights include:</p>
<blockquote><p>In addition to bug fixes, this release includes the following major changes from 2.4.0:</p>
<ul>
<li> We now ship Microsoft&#8217;s <a title="http://www.asp.net/mvc" rel="nofollow" href="http://www.asp.net/mvc">ASP.NET MVC</a><span> (<em>http://www.asp.net/mvc</em>)</span> stack and ASP.NET MVC applications can run with Mono.</li>
<li> xbuild has been updated</li>
<li> Removed non-free amqp0-8.xml documentation.</li>
</ul>
</blockquote>
<p>More detailed information can be found &#8220;<a href="http://www.mono-project.com/Release_Notes_Mono_2.4.2">http://www.mono-project.com/Release_Notes_Mono_2.4.2</a>&#8220;. I have to say the MVC part is really exciting for me, again for cloud and cross OS capabilities this seems a winner!</p>
<p>Now on to the other side of the news &#8211; I almost blogged about this earlier, but it seems good prudence as we now can have the good news of the new release with the less good of people saying don&#8217;t use it!</p>
<p>Richard Stallman is recommending against using C# as a platform for free software in his &#8220;<a href="http://www.fsf.org/news/dont-depend-on-mono">Why free software shouldn&#8217;t depend on Mono or C#</a>&#8220;. This obviously got a big slashdot following at <a href="http://news.slashdot.org/story/09/06/27/1759255/Richard-Stallman-Says-No-To-Mono">http://news.slashdot.org/story/09/06/27/1759255/Richard-Stallman-Says-No-To-Mono</a>. While I understand his sentiments I dont believe that his thoughts on Microsoft pulling C# support using patents is any more of a threat than any other language (aka everything has patent exposure &#8211; its not language specific). Actually I&#8217;ve been very impressed with Microsoft recently on their move towards interoperability and their more open support of open systems. Adding fanning the flames was this <a href="http://www2.apebox.org/wordpress/rants/124/">Here we go again – why Mono doesn’t suck</a>. Ah I had forgotten about the joys of how much can be written about a emotive topic in such a short period of time <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Gareth</p>
]]></content:encoded>
			<wfw:commentRss>http://www.csharphacker.com/technicalblog/index.php/2009/06/29/mono-in-the-news-again-2-4-2-released-with-mvc-support-and-stallman-against-mono/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Morning C# news &#8211; and more</title>
		<link>http://www.csharphacker.com/technicalblog/index.php/2009/06/29/morning-c-news-and-more/</link>
		<comments>http://www.csharphacker.com/technicalblog/index.php/2009/06/29/morning-c-news-and-more/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 13:07:46 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Data Warehousing]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.csharphacker.com/technicalblog/?p=265</guid>
		<description><![CDATA[This one has just been reported, but if you havnt seen it - it is very exciting!

    * Mono on the iPhone.... To say this is exciting is an understatement. Unfortunately I'm a little afraid that Apple wont like it too much (read allow it in their TOS). Mono isnormally an interpreted l...

]]></description>
			<content:encoded><![CDATA[<p>This one has just been reported, but if you havnt seen it &#8211; it is very exciting!</p>
<ul>
<li><a href="http://tirania.org/blog/archive/2009/Jun-29.html">Mono on the iPhone</a>&#8230;. To say this is exciting is an understatement. Unfortunately I&#8217;m a little afraid that Apple wont like it too much (read allow it in their TOS).<br />
<blockquote><p>&#8220;3.3.2 An Application may not itself install or launch other executable code by any means, including without limitation through the use of a plug-in architecture, calling other frameworks, other APIs or otherwise. No interpreted code may be downloaded and used in an Application except for code that is interpreted and run by Apple&#8217;s Published APIs and built-in interpreter(s)&#8221;</p></blockquote>
<p>.Mono is normally an interpreted language very similar to Java and the TOS explictly disallows running byte code on the machine.  So this could be VERY interesting, or it could be a nice concept and not never to hit the Apple store. Definitely watch this space!Otherwise we will end up with a compiler than generates Object C code <img src='http://www.csharphacker.com/technicalblog/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </li>
<li><a href="http://www.theregister.co.uk/2009/06/29/firefox_3_5/">Firefox 3.5 should be out tomorrow</a>.</li>
<li>Another EDW appliance comes into the fold with <a href="http://www.dbms2.com/2009/06/29/aster-data-ncluster-mapreduce-appliance/">Aster Data</a>.</li>
<li>Simple problems highlighted with &#8220;<a href="http://sqlblogcasts.com/blogs/simons/archive/2009/06/29/Hyperlinks-in-custom-reports.aspx">SQL Server 2005 reporting in management studio</a>&#8220;.</li>
</ul>
<p>Gareth</p>
]]></content:encoded>
			<wfw:commentRss>http://www.csharphacker.com/technicalblog/index.php/2009/06/29/morning-c-news-and-more/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
