<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>The Public Void</title>
	<atom:link href="http://andrewtwest.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://andrewtwest.com</link>
	<description>Andy West&#039;s Blog: Software Development and More</description>
	<lastBuildDate>Sun, 16 Jun 2013 21:45:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='andrewtwest.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/c0281a895b7e49563079e2f09831f4c2?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>The Public Void</title>
		<link>http://andrewtwest.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://andrewtwest.com/osd.xml" title="The Public Void" />
	<atom:link rel='hub' href='http://andrewtwest.com/?pushpress=hub'/>
		<item>
		<title>Micro-ORMs for .NET Compared – Part 3</title>
		<link>http://andrewtwest.com/2012/08/21/micro-orms-for-net-compared-part-3/</link>
		<comments>http://andrewtwest.com/2012/08/21/micro-orms-for-net-compared-part-3/#comments</comments>
		<pubDate>Wed, 22 Aug 2012 04:27:09 +0000</pubDate>
		<dc:creator>Andy West</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[micro-orm]]></category>
		<category><![CDATA[petapoco]]></category>

		<guid isPermaLink="false">http://andrewtwest.com/?p=505</guid>
		<description><![CDATA[This is the final part of a 3-part series comparing micro-ORMs.  We’ve already seen Dapper and Massive.  Now it’s time for PetaPoco. PetaPoco Website: http://www.toptensoftware.com/petapoco/ Code: https://github.com/toptensoftware/petapoco NuGet: http://nuget.org/packages/PetaPoco Databases supported: SQL Server, SQL Server CE, Oracle, PostgreSQL, MySQL Size: 2330 lines of code Description PetaPoco was, like the website states, “inspired by Rob Conery&#8217;s [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewtwest.com&#038;blog=12038026&#038;post=505&#038;subd=andrewtwest&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This is the final part of a 3-part series comparing micro-ORMs.  We’ve already seen <a href="http://andrewtwest.com/2012/08/19/micro-orms-for-net-compared-part-1/">Dapper </a>and <a href="http://andrewtwest.com/2012/08/20/micro-orms-for-net-compared-part-2/">Massive</a>.  Now it’s time for PetaPoco.</p>
<h3>PetaPoco</h3>
<p>Website: <a href="http://www.toptensoftware.com/petapoco/">http://www.toptensoftware.com/petapoco/</a><br />
Code: <a href="https://github.com/toptensoftware/petapoco">https://github.com/toptensoftware/petapoco</a><br />
NuGet: <a href="http://nuget.org/packages/PetaPoco">http://nuget.org/packages/PetaPoco</a></p>
<p>Databases supported: SQL Server, SQL Server CE, Oracle, PostgreSQL, MySQL<br />
Size: 2330 lines of code</p>
<h4>Description</h4>
<p>PetaPoco was, like the website states, “inspired by Rob Conery&#8217;s Massive project but for use with non-dynamic POCO objects.”  A couple of the more notable features include T4 templates to automatically generate POCO classes, and a low-friction SQL builder class</p>
<h4>Installation</h4>
<p>There are two packages available to install: <strong>Core Only</strong> and <strong>Core + T4 Templates</strong>.  I chose the one with templates, which raises a dialog with the following message:</p>
<blockquote><p>“Running this text template can potentially harm your computer.  Do not run it if you obtained it from an untrusted source.”</p></blockquote>
<p>PetaPoco has a click-to-accept Apache License.  If your project is a console application, you’ll need to add an <strong>App.config</strong> file.</p>
<h4>Usage</h4>
<p>Because PetaPoco uses POCOs, it looks more like Dapper than Massive at first glance:</p>
<pre class="brush: csharp; title: ; notranslate">
class Product
{
    public int ProductId { get; set; }
    public string ProductName { get; set; }
}

class Program
{
    private static void Main(string[] args)
    {
        var db = new Database(&quot;northwind&quot;);
        var products = db.Query(&quot;SELECT * FROM Products&quot;);
    }
}
</pre>
<p>There is also experimental support for “dynamic” queries if you need them:</p>
<pre class="brush: csharp; title: ; notranslate">
var products = db.Query(&quot;SELECT * FROM Products&quot;);
</pre>
<p>PetaPoco has a lot of cool features, including paged fetches (a wheel I’ve reinvented far too many times):</p>
<pre class="brush: csharp; title: ; notranslate">
var pagedResult = db.Page(sql: &quot;SELECT * FROM Products&quot;,
    page: 2, itemsPerPage: 20);

foreach (var product in pagedResult.Items)
{
    Console.WriteLine(&quot;{0} - {1}&quot;, product.ProductId,
        product.ProductName);
}
</pre>
<p>While POCOs give you the benefit of static typing, and <strong>System.Dynamic</strong> frees you from the burden of defining all your objects by hand, templates attempt to give you the best of both worlds.</p>
<p>The first thing you have to do the use templates is ensure that your connection string has a provider name.  Otherwise the code generator will fail.  Then you must configure the <strong>Database.tt</strong> file.  I changed the following lines:</p>
<pre class="brush: plain; title: ; notranslate">
ConnectionStringName = &quot;northwind&quot;;  // Uses last connection string in config if not specified
Namespace = &quot;Northwind&quot;;
</pre>
<p>When you save it, you might get a security warning because Visual Studio is about to generate code from the template.  You can dismiss the warning if you haven’t already.</p>
<p>Now you can use the generated POCOs in your code:</p>
<pre class="brush: csharp; title: ; notranslate">
var products = Northwind.Product.Query(&quot;SELECT * FROM Products&quot;);
</pre>
<h4>First Impressions</h4>
<p>PetaPoco is surprisingly full-featured for a micro-ORM while maintaining a light feel and small code size.  There is too much to show in a single blog post, so you should check out <a href="http://www.toptensoftware.com/petapoco/">the PetaPoco website</a> for a full description of what this tool is capable of.</p>
<h2>Final Comparison</h2>
<p>All of these micro-ORMs fill a similar need, which is to replace a full-featured ORM with something smaller, simpler, and potentially faster.  That said, each one has its own strengths and weaknesses.  Here are my recommendations based on my own limited testing.</p>
<table>
<tbody>
<tr>
<td><strong><em>You should consider&#8230;</em></strong></td>
<td><strong><em>If you’re looking for&#8230;</em></strong></td>
</tr>
<tr>
<td>Dapper</td>
<td>Performance, proven stability</td>
</tr>
<tr>
<td>Massive</td>
<td>Tiny size, flexibility</td>
</tr>
<tr>
<td>PetaPoco</td>
<td>POCOs without the pain, more features</td>
</tr>
</tbody>
</table>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andrewtwest.wordpress.com/505/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andrewtwest.wordpress.com/505/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewtwest.com&#038;blog=12038026&#038;post=505&#038;subd=andrewtwest&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://andrewtwest.com/2012/08/21/micro-orms-for-net-compared-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/257794d1a5b0dbab1ecd6eeb33975693?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy West</media:title>
		</media:content>
	</item>
		<item>
		<title>Micro-ORMs for .NET Compared – Part 2</title>
		<link>http://andrewtwest.com/2012/08/20/micro-orms-for-net-compared-part-2/</link>
		<comments>http://andrewtwest.com/2012/08/20/micro-orms-for-net-compared-part-2/#comments</comments>
		<pubDate>Tue, 21 Aug 2012 03:45:09 +0000</pubDate>
		<dc:creator>Andy West</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[massive]]></category>
		<category><![CDATA[micro-orm]]></category>

		<guid isPermaLink="false">http://andrewtwest.com/?p=494</guid>
		<description><![CDATA[This is Part 2 of a 3-part series.  Last time we took a look at Dapper.  This time we’ll see what Massive has to offer. Massive Website: http://blog.wekeroad.com/helpy-stuff/and-i-shall-call-it-massive Code: https://github.com/robconery/massive NuGet: http://www.nuget.org/packages/Massive Databases supported: SQL Server, Oracle, PostgreSQL, SQLite Size: 673 lines of code Description Massive was created by Rob Conery.  It relies heavily on [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewtwest.com&#038;blog=12038026&#038;post=494&#038;subd=andrewtwest&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This is Part 2 of a 3-part series.  <a href="http://andrewtwest.com/2012/08/19/micro-orms-for-net-compared-part-1/">Last time</a> we took a look at Dapper.  This time we’ll see what Massive has to offer.</p>
<h3>Massive</h3>
<p>Website: <a href="http://blog.wekeroad.com/helpy-stuff/and-i-shall-call-it-massive">http://blog.wekeroad.com/helpy-stuff/and-i-shall-call-it-massive</a><br />
Code: <a href="https://github.com/robconery/massive">https://github.com/robconery/massive</a><br />
NuGet: <a href="http://www.nuget.org/packages/Massive">http://www.nuget.org/packages/Massive</a></p>
<p>Databases supported: SQL Server, Oracle, PostgreSQL, SQLite<br />
Size: 673 lines of code</p>
<h4>Description</h4>
<p>Massive was created by Rob Conery.  It relies heavily on the dynamic features of C# 4 and makes extensive use of the ExpandoObject.  It has no dependencies besides what’s in the GAC.</p>
<h4>Installation</h4>
<p>Unlike Dapper and PetaPoco, Massive does not show up in a normal NuGet search.  You’ll have to go to the <strong>Package Manager Console</strong> and type “Install-Package Massive -Version 1.1” to install it.  If your solution has multiple projects, make sure you select the correct default project first.</p>
<p>If your project is a console application, you’ll need to add a reference to System.Configuration.</p>
<h4>Usage</h4>
<p>Despite its name, Massive is tiny.  Weighing in at under 700 lines of code, it is the smallest micro-ORM I tested.  Because it uses dynamics and creates a connection itself, you can get up and running with very little code indeed:</p>
<pre class="brush: csharp; title: ; notranslate">
class Products : DynamicModel
{
    public Products() : base(&quot;northwind&quot;, primaryKeyField: &quot;ProductID&quot;) { }
}

class Program
{
    private static void Main(string[] args)
    {
        var tbl = new Products();
        var products = tbl.All();
    }
}
</pre>
<p>It’s great not having to worry about setting up POCO properties by hand, and depending on your application, this could save you some work when your database schema changes.</p>
<p>However, the fact that this tool relies on System.Dynamic is also its biggest weakness.  You can’t use Visual Studio’s Intellisense to discover properties on returned results, and if you mistype the name of a property, you won’t know it until runtime.  Like most things in life, there are tradeoffs.  If you’re terrified of “<a href="http://blog.wekeroad.com/helpy-stuff/and-i-shall-call-it-massive">scary hippy code</a>”, then this could be a problem.</p>
<h4>First Impressions</h4>
<p>Massive is very compact and extremely flexible as a result of the design choice to use dynamics.  If you’re willing to code without the Intellisense safety net and can live without static typing, it’s a great way to keep your data mapping simple.</p>
<p><a href="http://andrewtwest.com/2012/08/21/micro-orms-for-net-compared-part-3/"><em><em>Continue to Part 3…</em></em></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andrewtwest.wordpress.com/494/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andrewtwest.wordpress.com/494/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewtwest.com&#038;blog=12038026&#038;post=494&#038;subd=andrewtwest&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://andrewtwest.com/2012/08/20/micro-orms-for-net-compared-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/257794d1a5b0dbab1ecd6eeb33975693?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy West</media:title>
		</media:content>
	</item>
		<item>
		<title>Micro-ORMs for .NET Compared &#8211; Part 1</title>
		<link>http://andrewtwest.com/2012/08/19/micro-orms-for-net-compared-part-1/</link>
		<comments>http://andrewtwest.com/2012/08/19/micro-orms-for-net-compared-part-1/#comments</comments>
		<pubDate>Mon, 20 Aug 2012 03:18:26 +0000</pubDate>
		<dc:creator>Andy West</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[dapper]]></category>
		<category><![CDATA[micro-orm]]></category>

		<guid isPermaLink="false">http://andrewtwest.com/?p=464</guid>
		<description><![CDATA[Recently, I have been made aware of a lightweight alternative to full-blown ORMs like NHibernate and Entity Framework.  They’re called micro-ORMs, and I decided to test-drive a few of the more popular ones to see how they compare. Each of the tools listed here are small and contained within a single file (hence the “micro” [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewtwest.com&#038;blog=12038026&#038;post=464&#038;subd=andrewtwest&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Recently, <a href="http://lostechies.com/jimmybogard/2012/07/20/choosing-an-orm-strategy/">I have been made aware</a> of a lightweight alternative to full-blown ORMs like NHibernate and Entity Framework.  They’re called micro-ORMs, and I decided to test-drive a few of the more popular ones to see how they compare.</p>
<p>Each of the tools listed here are small and contained within a single file (hence the “micro” part of the name).  If you’re adventurous, it’s worth having a look at the code since they use some interesting and powerful techniques to implement their mapping, such as Reflection.Emit, C# 4 dynamic features, and T4 templates.</p>
<h2 id="internal-source-marker_0.7899862055714241">The Software</h2>
<h3>Dapper</h3>
<p>Website: <a href="http://code.google.com/p/dapper-dot-net/">http://code.google.com/p/dapper-dot-net/</a><br />
GitHub: <a href="https://github.com/SamSaffron/dapper-dot-net">https://github.com/SamSaffron/dapper-dot-net</a><br />
NuGet: <a href="http://nuget.org/packages/Dapper">http://nuget.org/packages/Dapper</a></p>
<p>Databases supported: Any database with an ADO.NET provider<br />
Size: 2345 lines of code</p>
<h4 id="internal-source-marker_0.7899862055714241">Description</h4>
<p>Dapper was written by Sam Saffron and Marc Gravell and is used by the popular programmer site <a href="http://stackoverflow.com/">Stack Overflow</a>.  It’s designed with an emphasis on performance, and even uses <a href="http://msdn.microsoft.com/en-us/library/system.reflection.emit.aspx">Reflection.Emit</a> to generate code on-the-fly internally.  The Dapper website has metrics to show its performance relative to other ORMs.</p>
<p>Among Dapper’s features are list support, buffered and unbuffered readers, multi mapping, and multiple result sets.</p>
<h4 id="internal-source-marker_0.7899862055714241">Installation</h4>
<p>In Visual Studio, use <strong>Manage NuGet Packages</strong>, search for “Dapper”, and click <strong>Install</strong>.  Couldn’t be easier.</p>
<h4 id="internal-source-marker_0.7899862055714241">Usage</h4>
<p>Here we select all rows from a Products table and return a collection of Product objects:</p>
<pre class="brush: csharp; title: ; notranslate">
class Product
{
    public int ProductId { get; set; }
    public string ProductName { get; set; }
}

class Program
{
    private static void Main(string[] args)
    {
        using (var conn = new SqlConnection(&quot;Data Source=.\\SQLEXPRESS;
            Initial Catalog=Northwind;Integrated Security=SSPI;&quot;))
        {
            conn.Open();
            var products = conn.Query&lt;Product&gt;(&quot;SELECT * FROM Products&quot;);
        }
    }
}
</pre>
<p>As you can see from the example, Dapper expects an open connection, so you have to set that up yourself.  It’s also picky about data types when mapping to a strongly typed list.  For example, if you try to map a 16-bit database column to a 32-bit int property you’ll get a column parsing error.  Mapping is case-insensitive, and you can map to objects that have missing or extra properties compared with the columns you are mapping from.</p>
<p>Dapper can output a collection of dynamic objects if you use <strong>Query()</strong> instead of <strong>Query&lt;T&gt;()</strong>:</p>
<pre class="brush: csharp; title: ; notranslate">
    var shippers = conn.Query(&quot;SELECT * FROM Shippers&quot;);
</pre>
<p>This saves you the tedium of defining objects just for mapping.</p>
<p>Dapper supports parameterized queries where the parameters are passed in as anonymous classes:</p>
<pre class="brush: csharp; title: ; notranslate">
    var customers =
        conn.Query(&quot;SELECT * FROM Customers WHERE Country = @Country
            AND ContactTitle = @ContactTitle&quot;,
        new { Country = &quot;Canada&quot;, ContactTitle = &quot;Marketing Assistant&quot; });
</pre>
<p>The multi mapping feature is handy and lets you map one row to multiple objects:</p>
<pre class="brush: csharp; title: ; notranslate">
class Order
{
    public int OrderId { get; set; }
    public string CustomerId { get; set; }
    public Customer Customer { get; set; }
    public DateTime OrderDate { get; set; }
}

class Customer
{
    public string CustomerId { get; set; }
    public string City { get; set; }
}

...

var sql =
    @&quot;SELECT * FROM
        Orders o
        INNER JOIN Customers c
            ON c.CustomerID = o.CustomerID
    WHERE
        c.ContactName = 'Bernardo Batista'&quot;;

var orders = conn.Query&lt;order, customer,=&quot;&quot; order=&quot;&quot;&gt;(sql,
    (order, customer) =&gt; { order.Customer = customer; return order; },
    splitOn: &quot;CustomerID&quot;);

var firstOrder = orders.First();

Console.WriteLine(&quot;Order date: {0}&quot;, firstOrder.OrderDate.ToShortDateString());

Console.WriteLine(&quot;Customer city: {0}&quot;, firstOrder.Customer.City);
</pre>
<p>Here, the <strong>Customer</strong> property of the <strong>Order</strong> class does not correspond to a database column.  Instead, it will be populated with customer data that was joined to the order in the query.</p>
<p>Make sure to join tables in the right order or you may not get back the results you expect.</p>
<h4>First Impressions</h4>
<p>Dapper is slightly larger than some other micro-ORMs, but its focus on raw performance means that it excels in that area.  It is flexible and works with POCOs or dynamic objects, and its use on the Stack Overflow website suggests that it is stable and well-tested.</p>
<p><a href="http://andrewtwest.com/2012/08/20/micro-orms-for-net-compared-part-2/"><em>Continue to Part 2&#8230;</em></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andrewtwest.wordpress.com/464/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andrewtwest.wordpress.com/464/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewtwest.com&#038;blog=12038026&#038;post=464&#038;subd=andrewtwest&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://andrewtwest.com/2012/08/19/micro-orms-for-net-compared-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/257794d1a5b0dbab1ecd6eeb33975693?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy West</media:title>
		</media:content>
	</item>
		<item>
		<title>Ignoring ReSharper Code Issues in Your New ASP.NET MVC 3 Application</title>
		<link>http://andrewtwest.com/2011/07/22/ignoring-resharper-code-issues-in-your-new-asp-net-mvc-3-application/</link>
		<comments>http://andrewtwest.com/2011/07/22/ignoring-resharper-code-issues-in-your-new-asp-net-mvc-3-application/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 22:19:39 +0000</pubDate>
		<dc:creator>Andy West</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[analysis]]></category>
		<category><![CDATA[asp.net mvc]]></category>
		<category><![CDATA[code issues]]></category>
		<category><![CDATA[resharper]]></category>

		<guid isPermaLink="false">http://andrewtwest.com/?p=446</guid>
		<description><![CDATA[ReSharper is a great tool for identifying problems with your code.  Simply right-click on any project in the Solution Explorer and select Find Code Issues.  After ReSharper analyzes all the files, you’ll see a window with several categories of issues including “Common Practices and Code Improvements”, “Constraint Violations”, and “Potential Code Quality Issues”. Unfortunately, when [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewtwest.com&#038;blog=12038026&#038;post=446&#038;subd=andrewtwest&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:left;">ReSharper is a great tool for identifying problems with your code.  Simply right-click on any project in the Solution Explorer and select <strong>Find Code Issues</strong>.  After ReSharper analyzes all the files, you’ll see a window with several categories of issues including “Common Practices and Code Improvements”, “Constraint Violations”, and “Potential Code Quality Issues”.</p>
<p>Unfortunately, when you create a new ASP.NET MVC 3 application in Visual Studio 2010, Resharper will find thousands of code issues before you even start coding.</p>
<p><a href="http://andrewtwest.files.wordpress.com/2011/07/codeissues1.png"><img class="aligncenter size-full wp-image-447" title="2019 issues found" src="http://andrewtwest.files.wordpress.com/2011/07/codeissues1.png?w=497&#038;h=335" alt="2019 issues found" width="497" height="335" /></a></p>
<p>Most of these “issues” are in jQuery and Microsoft’s AJAX libraries, and your average developer is not going to go around adding semicolons all day when they have real work to do.  So we need to tell ReSharper to ignore these known issues somehow.</p>
<p>It would be nice if ReSharper allowed you to ignore files using file masks, but it doesn’t.  You must specify each file or folder individually.  Go to<strong> ReSharper-&gt;Options&#8230;-&gt;Code Inspection-&gt;Settings</strong>.  Click <strong>Edit Items to Skip</strong>.</p>
<p>My first instinct was to lasso or shift-click to select all the jQuery scripts, but this is not allowed!  I certainly wasn’t going to bounce back and forth between dialog windows a dozen times just to add each file.</p>
<p>Luckily this is ReSharper, and we can move all the script files into another directory and update references automatically.  Select all the jQuery scripts in the <strong>Scripts</strong> folder simultaneously, right-click, and go to <strong>Refactor-&gt;Move</strong>.  Create a new <strong>jquery</strong> folder under <strong>Scripts</strong> and click Next.</p>
<p><a href="http://andrewtwest.files.wordpress.com/2011/07/codeissues2.png"><img class="aligncenter size-full wp-image-449" title="Move to Folder" src="http://andrewtwest.files.wordpress.com/2011/07/codeissues2.png?w=497&#038;h=432" alt="Move to Folder" width="497" height="432" /></a><a href="http://andrewtwest.files.wordpress.com/2011/07/codeissues1.png"><br />
</a><br />
Now you can go back into the ReSharper options and add this folder to the list of items to skip.</p>
<p><a href="http://andrewtwest.files.wordpress.com/2011/07/codeissues3.png"><img class="aligncenter size-full wp-image-452" title="Skip jQuery folder" src="http://andrewtwest.files.wordpress.com/2011/07/codeissues3.png?w=497" alt="Skip jQuery folder"   /></a></p>
<p>Move Microsoft’s script files into their own folder, and tell ReSharper to ignore these as well.  I’m also using modernizr so I exluded the two modernizr scripts individually.</p>
<p><a href="http://andrewtwest.files.wordpress.com/2011/07/codeissues4.png"><img class="aligncenter size-full wp-image-453" title="Skip Files and Folders" src="http://andrewtwest.files.wordpress.com/2011/07/codeissues4.png?w=497" alt="Skip Files and Folders"   /></a></p>
<p><strong>Find Code Issues</strong> again and things should look much better.  I’ve only got 25 issues now.</p>
<p style="text-align:left;"><a href="http://andrewtwest.files.wordpress.com/2011/07/codeissues5.png"><img class="aligncenter size-full wp-image-454" title="25 code issues" src="http://andrewtwest.files.wordpress.com/2011/07/codeissues5.png?w=497" alt="25 code issues"   /></a></p>
<p>With the help of ReSharper’s refactoring capabilities I was able to get this down to one issue in just a few minutes.  Now you can get on with your project without having to mentally filter out a bunch of noise in the Inspection Results window.</p>
<p>Happy coding!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andrewtwest.wordpress.com/446/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andrewtwest.wordpress.com/446/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewtwest.com&#038;blog=12038026&#038;post=446&#038;subd=andrewtwest&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://andrewtwest.com/2011/07/22/ignoring-resharper-code-issues-in-your-new-asp-net-mvc-3-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/257794d1a5b0dbab1ecd6eeb33975693?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy West</media:title>
		</media:content>

		<media:content url="http://andrewtwest.files.wordpress.com/2011/07/codeissues1.png" medium="image">
			<media:title type="html">2019 issues found</media:title>
		</media:content>

		<media:content url="http://andrewtwest.files.wordpress.com/2011/07/codeissues2.png" medium="image">
			<media:title type="html">Move to Folder</media:title>
		</media:content>

		<media:content url="http://andrewtwest.files.wordpress.com/2011/07/codeissues3.png" medium="image">
			<media:title type="html">Skip jQuery folder</media:title>
		</media:content>

		<media:content url="http://andrewtwest.files.wordpress.com/2011/07/codeissues4.png" medium="image">
			<media:title type="html">Skip Files and Folders</media:title>
		</media:content>

		<media:content url="http://andrewtwest.files.wordpress.com/2011/07/codeissues5.png" medium="image">
			<media:title type="html">25 code issues</media:title>
		</media:content>
	</item>
		<item>
		<title>An HTML5 Music Visualizer for Dev:Unplugged</title>
		<link>http://andrewtwest.com/2011/04/30/an-html5-music-visualizer-for-devunplugged/</link>
		<comments>http://andrewtwest.com/2011/04/30/an-html5-music-visualizer-for-devunplugged/#comments</comments>
		<pubDate>Sat, 30 Apr 2011 23:17:59 +0000</pubDate>
		<dc:creator>Andy West</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[pinned sites]]></category>
		<category><![CDATA[visualizer]]></category>

		<guid isPermaLink="false">http://andrewtwest.com/?p=426</guid>
		<description><![CDATA[HTML5 is Here Although HTML5 is still in development, the latest generation of popular browsers (those released within the past month or so) support a surprisingly consistent set of HTML5 features.  This allows developers to start seriously targeting the future standard and taking advantage of its many benefits. The Contest Microsoft is currently running a [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewtwest.com&#038;blog=12038026&#038;post=426&#038;subd=andrewtwest&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<h2>HTML5 is Here</h2>
<p>Although HTML5 is still in development, the latest generation of popular browsers (those released within the past month or so) support a surprisingly consistent set of HTML5 features.  This allows developers to start seriously targeting the future standard and taking advantage of its many benefits.</p>
<h2>The Contest</h2>
<p>Microsoft is currently running a contest called <a href="http://www.beautyoftheweb.com/#/unplugged/" target="_blank">{Dev:Unplugged}</a> that gives Web developers the opportunity to showcase their HTML5 skills.  Entrants have the option of creating a game or music-related site, and compete for some awesome prizes.  On May 9, an expert team of judges will start evaluating entries based on several criteria such as creativity, quality, and fit with the contest theme.</p>
<h2>My Entry: <a href="https://microsoft.promo.eprize.com/ie9app/gallery?id=202" target="_blank">html5beats.com</a></h2>
<div style="margin-top:20px;margin-bottom:20px;"><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='497' height='310' src='http://www.youtube.com/embed/laLWEgpXhKM?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></div>
<h3>What it is</h3>
<p>html5beats is a music visualizer that generates real time animations that respond to the beat of the music.  In the past you had to use Flash or embedded media players to accomplish this.  With HTML5 you can do it with JavaScript and markup alone.</p>
<h3>How it works</h3>
<p>To synchronize audio and video, you must have access to the raw audio data.  Unfortunately, browsers don’t offer provide this access in a consistent way (and some don’t offer it at all).  I wrote a small C# program that preprocesses the sound files and I add the output (RMS amplitude) to a JavaScript file.  It doesn&#8217;t need to be high resolution (8 bit, 40Hz) so it works out to only about 20KB per song.  At first I thought I invented this method, but I Googled around and discovered that someone else <a href="http://gskinner.com/blog/archives/2011/03/music-visualizer-in-html5-js-with-source-code.html" target="_blank">beat me to it</a>.  Nevertheless, it works well in practice and provides interesting results.</p>
<h3>Features</h3>
<h4>Cross-browser compatibility</h4>
<p>The following browsers are officially supported:</p>
<ul>
<li><a href="http://windows.microsoft.com/en-US/internet-explorer/products/ie/home" target="_blank">Internet Explorer 9</a> (recommended)</li>
<li><a href="http://www.google.com/chrome/index.html?hl=en&amp;brand=CHMA&amp;utm_campaign=en&amp;utm_source=en-ha-na-us-bk&amp;utm_medium=ha" target="_blank">Chrome 10</a></li>
<li><a href="http://www.opera.com/browser/" target="_blank">Opera 11</a></li>
<li><a href="http://www.mozilla.com/en-US/firefox/fx/" target="_blank">Firefox 4</a></li>
</ul>
<p>You can try other browsers with varying results.  Some will trigger a compatibility message, while others (like Firefox 3.6) will mostly work, but the site won’t look as good.</p>
<h4>Full screen mode</h4>
<p>The HTML5 canvas does not explicitly support full screen.  I solve this problem by using a second canvas that fills the entire page.  The image from the smaller main canvas is copied to the larger one every frame.  This may sound inefficient, but it performs well in all my tests.</p>
<h4>Lyrics</h4>
<p>This feature displays lyrics as the song plays, and can be turned on or off.  Although the canvas supports text directly, drawing straight to the canvas would interfere with some of the inter-frame effects I’m using.  Therefore, I position a div element over the canvas and change its inner text dynamically.</p>
<h4>Pinned site features</h4>
<p>Internet Explorer 9 offers a great new feature called “pinned sites” that provide Windows 7 desktop integration.  I’ve taken advantage of several pinned site features that enhance the user experience under IE9.</p>
<h5>Feature detection and discoverability</h5>
<p style="text-align:center;"><a href="http://andrewtwest.files.wordpress.com/2011/04/pinned_site_prompt1.png"><img class="aligncenter size-full wp-image-439" style="border:1px solid #d0d0d0;" title="Pinned site prompt" src="http://andrewtwest.files.wordpress.com/2011/04/pinned_site_prompt1.png?w=497&#038;h=183" alt="Pinned site prompt" width="497" height="183" /></a></p>
<p>If you’re browsing with IE9, html5beats will detect it and prompt you to try pinning the site.  If you don’t like seeing this prompt you can close it.  Pinning your site adds a high-quality icon to the taskbar and gives you access to additional functionality.</p>
<h5>Jump List</h5>
<p style="text-align:center;"><a href="http://andrewtwest.files.wordpress.com/2011/04/jump_list1.png"><img class="aligncenter size-full wp-image-440" style="border:1px solid #d0d0d0;" title="Jump List" src="http://andrewtwest.files.wordpress.com/2011/04/jump_list1.png?w=497" alt="Jump List"   /></a></p>
<p>Right-clicking the taskbar icon shows a Jump List with tasks that can take you directly to a specific page within the site, even if the browser isn’t currently open.</p>
<h5>Thumbnail Toolbar</h5>
<p style="text-align:center;"><a href="http://andrewtwest.files.wordpress.com/2011/04/thumbnail_toolbar1.png"><img class="aligncenter size-full wp-image-441" style="border:1px solid #d0d0d0;" title="Thumbnail toolbar" src="http://andrewtwest.files.wordpress.com/2011/04/thumbnail_toolbar1.png?w=497" alt="Thumbnail toolbar"   /></a></p>
<p>This is one of the coolest aspects of pinning the site.  Hovering over the taskbar reveals playback buttons so you can play, pause, and navigate songs even when the browser doesn’t have focus.</p>
<p><strong>Update</strong>: <em>Previous Track</em> and <em>Next Track</em> buttons have been added for additional control of the player.</p>
<h4>CSS3</h4>
<p>Until now, effects like rounded corners, shadows, and translucency were only available through browser-specific features, custom images, and elaborate CSS trickery.  CSS3 makes those techniques obsolete.  html5beats exploits CSS3 to improve the aesthetics of the main UI.</p>
<h2>Using the Code</h2>
<p>For now I’m disallowing use of the code, mainly to prevent someone from using it in a competing entry.  After the contest ends I plan on cleaning it up a bit and releasing it under an open-source license.</p>
<h2>Please Consider Supporting the Site with Your Vote</h2>
<p>In addition to a earning a high score from the judges, winning requires votes from the community.  If you like my entry, <a href="https://microsoft.promo.eprize.com/ie9app/gallery?id=202" target="_blank">please vote for it today</a>&#8230; there’s only one week left!  Also, look forward to new features and updates in the coming days &#8211; this is the home stretch.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andrewtwest.wordpress.com/426/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andrewtwest.wordpress.com/426/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewtwest.com&#038;blog=12038026&#038;post=426&#038;subd=andrewtwest&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://andrewtwest.com/2011/04/30/an-html5-music-visualizer-for-devunplugged/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/257794d1a5b0dbab1ecd6eeb33975693?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy West</media:title>
		</media:content>

		<media:content url="http://andrewtwest.files.wordpress.com/2011/04/pinned_site_prompt1.png" medium="image">
			<media:title type="html">Pinned site prompt</media:title>
		</media:content>

		<media:content url="http://andrewtwest.files.wordpress.com/2011/04/jump_list1.png" medium="image">
			<media:title type="html">Jump List</media:title>
		</media:content>

		<media:content url="http://andrewtwest.files.wordpress.com/2011/04/thumbnail_toolbar1.png" medium="image">
			<media:title type="html">Thumbnail toolbar</media:title>
		</media:content>
	</item>
		<item>
		<title>Profiling Built-In JavaScript Functions with Firebug</title>
		<link>http://andrewtwest.com/2011/03/26/profiling-built-in-javascript-functions-with-firebug/</link>
		<comments>http://andrewtwest.com/2011/03/26/profiling-built-in-javascript-functions-with-firebug/#comments</comments>
		<pubDate>Sat, 26 Mar 2011 19:27:01 +0000</pubDate>
		<dc:creator>Andy West</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[firebug]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[profiling]]></category>

		<guid isPermaLink="false">http://andrewtwest.com/?p=401</guid>
		<description><![CDATA[Firebug is a Web development tool for Firefox.  Among other things, it lets you profile your JavaScript code to find performance bottlenecks. To get started, simply go to the Firebug Web site, install the plugin, load a page in Firefox and activate Firebug.  Click the Profile button under the Console tab once to start profiling, [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewtwest.com&#038;blog=12038026&#038;post=401&#038;subd=andrewtwest&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Firebug  is a Web development tool for Firefox.  Among other things, it lets you  profile your JavaScript code to find performance bottlenecks.</p>
<p>To get started, simply go to the <a href="http://getfirebug.com/" target="_blank">Firebug Web site</a>, install the plugin, load a page in Firefox and activate Firebug.  Click the <strong>Profile </strong>button under the <strong>Console </strong>tab  once to start profiling, and again to stop it.  Firebug will display a  list of functions, the number of times they were called, and the time  spent in each one.</p>
<p>For example, here is a page that repeatedly draws a red rectangle and blue circle on the new HTML5 canvas:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;meta charset=&quot;utf-8&quot; /&gt;
        &lt;title&gt;Profiling Example&lt;/title&gt;
    &lt;/head&gt;
    &lt;body onload=&quot;drawShapes();&quot;&gt;
        &lt;canvas id=&quot;canvasElement&quot; width=&quot;200&quot; height=&quot;200&quot;&gt;
            Your browser does not support the HTML5 Canvas.
        &lt;/canvas&gt;
        &lt;script&gt;
            function drawShapes() {
                var canvasElement = document.getElementById('canvasElement');
                var context = canvasElement.getContext('2d');

                context.fillStyle = 'rgb(255, 0, 0)';

                // Draw a red rectangle many times.
                for (var i = 0; i &lt; 1000; i++)
                {
                    context.fillRect(30, 30, 50, 50);
                }

                context.fillStyle = 'rgb(0, 0, 255)';

                // Draw a blue circle many times.
                for (var i = 0; i &lt; 1000; i++)
                {
                    context.beginPath();
                    context.arc(70, 70, 15, Math.PI * 2, 0, true);
                    context.closePath();
                    context.fill();
                }
            }
        &lt;/script&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Let’s assume your code is taking a long time to execute.  Running the profile produces these results:</p>
<div id="attachment_402" class="wp-caption aligncenter" style="width: 507px"><a href="http://andrewtwest.files.wordpress.com/2011/03/profiling1.jpg" target="_blank"><img class="size-full wp-image-402 " title="Profiling Results 1" src="http://andrewtwest.files.wordpress.com/2011/03/profiling1.jpg?w=497&#038;h=315" alt="Profiling Results 1" width="497" height="315" /></a><p class="wp-caption-text">Click to enlarge</p></div>
<p>This  isn’t very useful because only user-defined functions show up.  There  is only one significant function here so there’s nothing to compare.  If  there were some way to profile built-in JavaScript functions, we might  get a better idea of which parts of the code are running slowly.</p>
<p><em>Note:  This is a contrived example written to illustrate a point.  It would be  just effective, and probably a better design overall, to extract two  methods named drawRectangle() and drawCircle().  See</em> <a href="http://www.refactoring.com/catalog/extractMethod.html" target="_blank">Extract Method</a><em>.</em></p>
<p>As a workaround, you could wrap some of the native functions and call the wrappers in your program code, like this:</p>
<pre class="brush: jscript; title: ; notranslate">
function drawShapes() {
    var canvasElement = document.getElementById('canvasElement');
    var context = canvasElement.getContext('2d');

    context.fillStyle = 'rgb(255, 0, 0)';

    // Draw a red rectangle many times.
    for (var i = 0; i &lt; 1000; i++)
    {
        fillRect(context, 30, 30, 50, 50);
    }

   context.fillStyle = 'rgb(0, 0, 255)';

    // Draw a blue circle many times.
    for (var i = 0; i &lt; 1000; i++)
    {
        context.beginPath();
        context.arc(70, 70, 15, Math.PI * 2, 0, true);
        context.closePath();
        fill(context);
    }
}

function fillRect(context, x, y, w, h) {
    context.fillRect(30, 30, 50, 50);
}

function fill(context) {
    context.fill();
}
</pre>
<p>But  that would impact your design and create unnecessary overhead.   Ideally, you’ll want a solution that’s only active during debugging and  doesn’t affect your production script.  One way to do this is to write  overrides for the native functions and store them in their own .js file (don&#8217;t forget to reference the script file in the HTML page):</p>
<pre class="brush: jscript; title: ; notranslate">
if (window.console.firebug !== undefined)
{
    var p = CanvasRenderingContext2D.prototype;

    p._fillRect = p.fillRect;
    p.fillRect = function (x, y, w, h) { this._fillRect(x, y, w, h) };

    p._fill = p.fill;
    p.fill = function () { this._fill() };
}
</pre>
<p>What  we’re doing here is saving the original function by assigning it to  another function with the same name, prefixed with an underscore.  Then  we’re writing over the original with our own function that does nothing  but wrap the old one.  This is enough to make it appear in the Firebug  profiling results.</p>
<div id="attachment_403" class="wp-caption aligncenter" style="width: 507px"><a href="http://andrewtwest.files.wordpress.com/2011/03/profiling2.jpg" target="_blank"><img class="size-full wp-image-403 " title="Profiling Results 2" src="http://andrewtwest.files.wordpress.com/2011/03/profiling2.jpg?w=497&#038;h=315" alt="Profiling Results 2" width="497" height="315" /></a><p class="wp-caption-text">Click to enlarge</p></div>
<p>The  beauty of this approach is that it only runs when the Firebug console  is turned on.  When it’s not, the conditional check fails and the code  block is not executed.  The check also fails in other browsers such as  IE9 and Chrome 11 beta, which is exactly what we want.</p>
<p>One  disadvantage is that you have to write a separate function for each  native function you want to override.  In the above example, a  significant amount of time is probably spent in context.arc(), but we  didn’t override it so there’s no way to tell.  It may be possible to  override and wrap every function in a specified object automatically,  but I haven’t tried that yet.  For now, I’ll leave it as an exercise for  the reader.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andrewtwest.wordpress.com/401/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andrewtwest.wordpress.com/401/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewtwest.com&#038;blog=12038026&#038;post=401&#038;subd=andrewtwest&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://andrewtwest.com/2011/03/26/profiling-built-in-javascript-functions-with-firebug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/257794d1a5b0dbab1ecd6eeb33975693?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy West</media:title>
		</media:content>

		<media:content url="http://andrewtwest.files.wordpress.com/2011/03/profiling1.jpg" medium="image">
			<media:title type="html">Profiling Results 1</media:title>
		</media:content>

		<media:content url="http://andrewtwest.files.wordpress.com/2011/03/profiling2.jpg" medium="image">
			<media:title type="html">Profiling Results 2</media:title>
		</media:content>
	</item>
		<item>
		<title>Workaround for NullReferenceException in DBComparer</title>
		<link>http://andrewtwest.com/2011/02/25/workaround-for-nullreferenceexception-in-dbcomparer/</link>
		<comments>http://andrewtwest.com/2011/02/25/workaround-for-nullreferenceexception-in-dbcomparer/#comments</comments>
		<pubDate>Sat, 26 Feb 2011 05:12:47 +0000</pubDate>
		<dc:creator>Andy West</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[DBComparer]]></category>
		<category><![CDATA[NullReferenceException]]></category>
		<category><![CDATA[workaround]]></category>

		<guid isPermaLink="false">http://andrewtwest.com/?p=393</guid>
		<description><![CDATA[DBComparer 3.0 is a great tool if you want to synchronize your SQL Server database environments and don’t have hundreds of dollars to spend on Red Gate’s SQL Compare.  It’s simple to use and free. http://dbcomparer.com/ I used it for a couple of weeks without any problem until one day when I tried to compare [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewtwest.com&#038;blog=12038026&#038;post=393&#038;subd=andrewtwest&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>DBComparer  3.0 is a great tool if you want to synchronize your SQL Server database  environments and don’t have hundreds of dollars to spend on Red Gate’s  SQL Compare.  It’s simple to use and free.</p>
<p><a href="http://dbcomparer.com/">http://dbcomparer.com/</a></p>
<p>I  used it for a couple of weeks without any problem until one day when I  tried to compare with a particular server and it crashed:</p>
<p><a href="http://andrewtwest.files.wordpress.com/2011/02/newcomparison.png"><img class="aligncenter size-full wp-image-394" title="DBComparer NullReferenceException" src="http://andrewtwest.files.wordpress.com/2011/02/newcomparison.png?w=497" alt="DBComparer NullReferenceException"   /></a></p>
<p>Looking  at the error message, we can deduce that the WriteRecentList() function  saves the names of the servers you have typed in the recent servers  list.  This is sort of like the recent files list found in some applications.</p>
<p>SettingsBase  is part of the .NET Framework, and this part of the code is probably  used to persist application settings.  A little digging around on the  MSDN library <a href="http://msdn.microsoft.com/en-us/library/system.configuration.localfilesettingsprovider.aspx">reveals this</a>:</p>
<blockquote><p>Specific  user data is stored in a file named user.config, stored under the  user&#8217;s home directory. If roaming profiles are enabled, two versions of  the user configuration file could exist. In such a case, the entries in  the roaming version take precedence over duplicated entries in the local  user configuration file.</p></blockquote>
<p>A  look in the user.config file confirms our theory that this is where the  list of recent servers are stored.  However, DBComparer is only  designed to support 10 recent server names (5 on each side of the  comparison).  Any more than that and it blows up.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;configuration&gt;
  &lt;userSettings&gt;
    &lt;DBCompare.Properties.Settings&gt;
      &lt;setting name=&quot;RecentServerName11&quot; serializeAs=&quot;String&quot;&gt;
        &lt;value&gt;server1&lt;/value&gt;
      &lt;/setting&gt;
      &lt;setting name=&quot;RecentServerName12&quot; serializeAs=&quot;String&quot;&gt;
        &lt;value&gt;server2&lt;/value&gt;
      &lt;/setting&gt;
      &lt;setting name=&quot;RecentServerName13&quot; serializeAs=&quot;String&quot;&gt;
        &lt;value&gt;server3&lt;/value&gt;
      &lt;/setting&gt;
      &lt;setting name=&quot;RecentServerName14&quot; serializeAs=&quot;String&quot;&gt;
        &lt;value&gt;server4&lt;/value&gt;
      &lt;/setting&gt;
      &lt;setting name=&quot;RecentServerName15&quot; serializeAs=&quot;String&quot;&gt;
        &lt;value&gt;server5&lt;/value&gt;
      &lt;/setting&gt;
      &lt;setting name=&quot;RecentServerName21&quot; serializeAs=&quot;String&quot;&gt;
        &lt;value&gt;server6&lt;/value&gt;
      &lt;/setting&gt;
      &lt;setting name=&quot;RecentServerName22&quot; serializeAs=&quot;String&quot;&gt;
        &lt;value&gt;server7&lt;/value&gt;
      &lt;/setting&gt;
      &lt;setting name=&quot;RecentServerName23&quot; serializeAs=&quot;String&quot;&gt;
        &lt;value&gt;server8&lt;/value&gt;
      &lt;/setting&gt;
      &lt;setting name=&quot;RecentServerName24&quot; serializeAs=&quot;String&quot;&gt;
         &lt;value&gt;server9&lt;/value&gt;
      &lt;/setting&gt;
      &lt;setting name=&quot;RecentServerName25&quot; serializeAs=&quot;String&quot;&gt;
        &lt;value&gt;server10&lt;/value&gt;
      &lt;/setting&gt;
    &lt;/DBCompare.Properties.Settings&gt;
  &lt;/userSettings&gt;
&lt;/configuration&gt;
</pre>
<p>As a workaround until this bug is fixed, you can delete some or all of the server names in the value tags to make room for more and prevent the error.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andrewtwest.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andrewtwest.wordpress.com/393/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewtwest.com&#038;blog=12038026&#038;post=393&#038;subd=andrewtwest&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://andrewtwest.com/2011/02/25/workaround-for-nullreferenceexception-in-dbcomparer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/257794d1a5b0dbab1ecd6eeb33975693?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy West</media:title>
		</media:content>

		<media:content url="http://andrewtwest.files.wordpress.com/2011/02/newcomparison.png" medium="image">
			<media:title type="html">DBComparer NullReferenceException</media:title>
		</media:content>
	</item>
		<item>
		<title>Same Markup, Same Browser, Different Results</title>
		<link>http://andrewtwest.com/2011/02/23/same-markup-same-browser-different-results/</link>
		<comments>http://andrewtwest.com/2011/02/23/same-markup-same-browser-different-results/#comments</comments>
		<pubDate>Thu, 24 Feb 2011 05:34:17 +0000</pubDate>
		<dc:creator>Andy West</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[compatibility view]]></category>
		<category><![CDATA[ie8]]></category>
		<category><![CDATA[intranet]]></category>
		<category><![CDATA[web standards]]></category>

		<guid isPermaLink="false">http://andrewtwest.com/?p=376</guid>
		<description><![CDATA[Here is a simple HTML5 page I created: And here is that page rendered in Internet Explorer 8.  In one case it’s being served on my laptop, and the other on the local intranet. The markup, the Web servers, and the browser are all set up 100% the same.  These should be identical, shouldn’t they? [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewtwest.com&#038;blog=12038026&#038;post=376&#038;subd=andrewtwest&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Here is a simple HTML5 page I created:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
 &lt;meta charset=&quot;utf-8&quot; /&gt;
 &lt;title&gt;Inconsistent Rendering&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
 &lt;span style=&quot;height: 1px; overflow: visible; background-color: Green;&quot;&gt;
 &lt;h1&gt;This is a test.&lt;/h1&gt;
 &lt;/span&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>And  here is that page rendered in Internet Explorer 8.  In one case it’s  being served on my laptop, and the other on the local intranet.</p>
<p><a href="http://andrewtwest.files.wordpress.com/2011/02/localhost.png"><img class="aligncenter size-full wp-image-379" title="Test file on localhost" src="http://andrewtwest.files.wordpress.com/2011/02/localhost.png?w=497" alt="Test file on localhost"   /></a></p>
<p><a href="http://andrewtwest.files.wordpress.com/2011/02/localhost.png"></a><a href="http://andrewtwest.files.wordpress.com/2011/02/intranet1.png"><img class="aligncenter size-full wp-image-383" title="Test file on intranet" src="http://andrewtwest.files.wordpress.com/2011/02/intranet1.png?w=497" alt="Test file on intranet"   /></a></p>
<p>The  markup, the Web servers, and the browser are all set up 100% the same.   These should be identical, shouldn’t they?  What’s the problem?  The  answer is Compatibility View.</p>
<p>Compatibility  View is a “feature” of Internet Explorer that causes it to ignore  modern Web standards.  That would be fine, except Compatibility View  settings vary by zone, and different zones have different defaults.   Also, the Compatibility View button in the address bar isn’t always  available, which means there’s no visual indicator as to what mode  you’re in, and you can’t change modes for the current page easily.</p>
<p>Compatibility  View settings can be accessed in the Tools &#8211;&gt; Compatibility View  Settings menu, but if you’ve developed a standards compliant intranet  site, you need a better fix than simply asking each individual user to  reconfigure their browser.  Group Policy is one option, but there is a  much simpler solution.  Just add the following meta tag to your pages,  and it will force IE 8 to use the !DOCTYPE declaration in the page to  determine the rendering mode.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=EmulateIE8&quot; /&gt;
</pre>
<p>If you&#8217;re experiencing rendering inconsistencies with the same markup being served from different environments, have a look into Compatibility View.  It just might be the culprit.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andrewtwest.wordpress.com/376/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andrewtwest.wordpress.com/376/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewtwest.com&#038;blog=12038026&#038;post=376&#038;subd=andrewtwest&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://andrewtwest.com/2011/02/23/same-markup-same-browser-different-results/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/257794d1a5b0dbab1ecd6eeb33975693?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy West</media:title>
		</media:content>

		<media:content url="http://andrewtwest.files.wordpress.com/2011/02/localhost.png" medium="image">
			<media:title type="html">Test file on localhost</media:title>
		</media:content>

		<media:content url="http://andrewtwest.files.wordpress.com/2011/02/intranet1.png" medium="image">
			<media:title type="html">Test file on intranet</media:title>
		</media:content>
	</item>
		<item>
		<title>Mercurial HTTP Error 500: Access is denied on 00changelog.i</title>
		<link>http://andrewtwest.com/2011/01/13/mercurial-http-error-500-access-is-denied-on-00changelog-i/</link>
		<comments>http://andrewtwest.com/2011/01/13/mercurial-http-error-500-access-is-denied-on-00changelog-i/#comments</comments>
		<pubDate>Fri, 14 Jan 2011 05:19:47 +0000</pubDate>
		<dc:creator>Andy West</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[00changelog]]></category>
		<category><![CDATA[access is denied]]></category>
		<category><![CDATA[hg]]></category>
		<category><![CDATA[http error 500]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[permissions]]></category>
		<category><![CDATA[push]]></category>

		<guid isPermaLink="false">http://andrewtwest.com/?p=362</guid>
		<description><![CDATA[Today I created a new Mercurial repository on a Windows server.  I cloned it, made some changes, tried to push, and was greeted with this: C:\myapplication&#62;hg push pushing to http://servername/myapplication searching for changes abort: HTTP Error 500: .hg\store0changelog.i: Access is denied My user account had write permission to the myapplication folder on the server, and [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewtwest.com&#038;blog=12038026&#038;post=362&#038;subd=andrewtwest&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Today  I created a new Mercurial repository on a Windows server.  I cloned it,  made some changes, tried to push, and was greeted with this:</p>
<p><code>C:\myapplication&gt;hg push<br />
pushing to <a href="http://servername/myapplication" rel="nofollow">http://servername/myapplication</a><br />
searching for changes<br />
abort: HTTP Error 500: .hg\store0changelog.i: Access is denied</code></p>
<p>My  user account had write permission to the <strong>myapplication </strong>folder on the  server, and the odd thing is that I’ve created repositories there before  and never had a problem pushing changes.  I compared <strong>00changelog.i</strong> to  the same file in another repository that was working.  Turns out I was using anonymous authentication and <strong>IUSR </strong>was missing write permission.  I gave full control to <strong>IUSR </strong>on <strong>hg\store</strong> folder and&#8230;</p>
<p><code>C:\myapplication&gt;hg push<br />
pushing to <a href="http://servername/myapplication" rel="nofollow">http://servername/myapplication</a><br />
searching for changes<br />
remote: adding changesets<br />
remote: adding manifests<br />
remote: adding file changes<br />
remote: added 1 changesets with 114 changes to 114 files</code></p>
<p>Success!</p>
<p>If  you’re having problems pushing to a central server with Mercurial, make  sure <del>the IIS anonymous authentication account (<strong>IUSR </strong>or  <strong>IUSR_<em>MachineName</em></strong>)</del> you have write permission to the <strong>hg\store</strong> folder and  subfolders in your repository.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andrewtwest.wordpress.com/362/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andrewtwest.wordpress.com/362/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewtwest.com&#038;blog=12038026&#038;post=362&#038;subd=andrewtwest&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://andrewtwest.com/2011/01/13/mercurial-http-error-500-access-is-denied-on-00changelog-i/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/257794d1a5b0dbab1ecd6eeb33975693?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy West</media:title>
		</media:content>
	</item>
		<item>
		<title>Conditional Validation with Data Annotations in ASP.NET MVC</title>
		<link>http://andrewtwest.com/2011/01/10/conditional-validation-with-data-annotations-in-asp-net-mvc/</link>
		<comments>http://andrewtwest.com/2011/01/10/conditional-validation-with-data-annotations-in-asp-net-mvc/#comments</comments>
		<pubDate>Tue, 11 Jan 2011 04:54:54 +0000</pubDate>
		<dc:creator>Andy West</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[asp.net mvc]]></category>
		<category><![CDATA[data annotations]]></category>
		<category><![CDATA[model state]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://andrewtwest.com/?p=340</guid>
		<description><![CDATA[In the simple blog engine I’m building, I encountered a scenario where I wanted to display different UI elements depending on whether the user was logged in: &#160; &#160; When the user is authenticated, their name and email is known, so it’s unnecessary to display them on the comment input form.  While it would be [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewtwest.com&#038;blog=12038026&#038;post=340&#038;subd=andrewtwest&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In  the <a href="https://bitbucket.org/andrewtwest/dotblog" target="_blank">simple blog engine</a> I’m building, I encountered a scenario where I  wanted to display different UI elements depending on whether the user  was logged in:</p>
<div id="attachment_346" class="wp-caption aligncenter" style="width: 303px"><a href="http://andrewtwest.files.wordpress.com/2011/01/leave_reply.png"><img class="size-full wp-image-346" style="border:1px solid #999999;" title="Comment Form" src="http://andrewtwest.files.wordpress.com/2011/01/leave_reply.png?w=497" alt="Comment Form"   /></a><p class="wp-caption-text">Not logged in</p></div>
<p>&nbsp;</p>
<div id="attachment_347" class="wp-caption aligncenter" style="width: 298px"><a href="http://andrewtwest.files.wordpress.com/2011/01/leave_reply_logged_in.png"><img class="size-full wp-image-347 " style="border:1px solid #999999;" title="Comment Form Logged In" src="http://andrewtwest.files.wordpress.com/2011/01/leave_reply_logged_in.png?w=497" alt="Comment Form Logged In"   /></a><p class="wp-caption-text">Logged in</p></div>
<p>&nbsp;</p>
<p>When  the user is authenticated, their name and email is known, so it’s  unnecessary to display them on the comment input form.  While it would  be possible to hide just those fields, I decided to make separate  partial views and display them in the Post view with the following code:</p>
<pre class="brush: csharp; title: ; notranslate">
&lt;%
    if (Model.AllowComments)
    {
        var commentControlName = Request.IsAuthenticated ? AuthenticatedCommentFormControl&quot; : &quot;CommentFormControl&quot;;
        Html.RenderPartial(commentControlName, new DotBlog.Models.ViewModels.CommentViewModel(Model.PostId));
    }
%&gt;
</pre>
<p>This is the view model I used for both partial views:</p>
<pre class="brush: csharp; title: ; notranslate">
public class CommentViewModel
{
    ...

    [Required]
    [StringLength(50)]
    [DisplayName(&quot;Name&quot;)]
    public string CommenterName { get; set; }

    public DateTime Date { get; set; }

    [Required]
    [StringLength(100)]
    public string Email { get; set; }

    [StringLength(100)]
    [DisplayName(&quot;Web Site&quot;)]
    public string WebSite { get; set; }

    [Required]
    [StringLength(1024)]
    [DisplayName(&quot;Comment&quot;)]
    public string CommentText { get; set; }

    ...
}
</pre>
<p>As  you can see, I’m using data annotations to enforce required fields and  string lengths.  The problem is, even though the name and email aren’t  always displayed, they are still required.  I needed a way to validate  certain fields conditionally.  Here are the options I came up with:</p>
<ul>
<li>Stop using data annotations and find a different solution for validation</li>
<li>Use two different view models: one for each partial view</li>
<li>Use actual conditional data annotations, like <a href="http://blogs.msdn.com/b/simonince/archive/2010/06/04/conditional-validation-in-mvc.aspx" target="_blank">the library built by Simon Ince</a>.</li>
<li>When the form is posted, remove the fields from the model state so they’re not validated.</li>
</ul>
<p>&nbsp;</p>
<p>Let’s look at each of these individually:</p>
<h2>Stop Using Data Annotations</h2>
<p>Data  annotations are not the only way to specify validation rules, but  they’re easy to implement.  xVal was fine for ASP.MVC 1.0, but is now  deprecated.  Custom validation code with ModelState.AddModelError() is  flexible, but requires extra work.</p>
<h2>Use Two Different View Models</h2>
<p>Since  I’m using two partial views for the comment form (one for authenticated  users and one for guests), I could use a dedicated view model for each.   One would omit the data annotations on name and email and therefore  not cause any validation problems.  This was my original implementation,  but lead to unnecessary code duplication and other design problems.</p>
<h2>Use Conditional Data Annotations</h2>
<p>Simon Ince has built <a href="http://blogs.msdn.com/b/simonince/archive/2010/06/04/conditional-validation-in-mvc.aspx" target="_blank">a cool library</a> for conditional annotations that allows you to write code like this:</p>
<pre class="brush: csharp; title: ; notranslate">
public class ValidationSample
{
    [RequiredIf(&quot;PropertyValidationDependsOn&quot;, true)]
    public string PropertyToValidate { get; set; }

    public bool PropertyValidationDependsOn { get; set; }
}
</pre>
<h2>Conditionally Remove Fields from the Model State in the Controller</h2>
<p>In the end, this is the solution I went with.  The controller executes this code when the form is posted:</p>
<pre class="brush: csharp; title: ; notranslate">
if (Request.IsAuthenticated)
{
    ...

    // We don't need to validate user fields if user is logged in.
    ModelState.Remove(&quot;CommenterName&quot;);
    ModelState.Remove(&quot;Email&quot;);
}
</pre>
<p>By  removing the fields from the model state, it won’t be invalid when they  are missing.  This method is simple and avoids adding additional  dependencies.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andrewtwest.wordpress.com/340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andrewtwest.wordpress.com/340/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewtwest.com&#038;blog=12038026&#038;post=340&#038;subd=andrewtwest&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://andrewtwest.com/2011/01/10/conditional-validation-with-data-annotations-in-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/257794d1a5b0dbab1ecd6eeb33975693?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy West</media:title>
		</media:content>

		<media:content url="http://andrewtwest.files.wordpress.com/2011/01/leave_reply.png" medium="image">
			<media:title type="html">Comment Form</media:title>
		</media:content>

		<media:content url="http://andrewtwest.files.wordpress.com/2011/01/leave_reply_logged_in.png" medium="image">
			<media:title type="html">Comment Form Logged In</media:title>
		</media:content>
	</item>
	</channel>
</rss>
