<?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>Tatham Oddie</title>
	<atom:link href="http://blog.tatham.oddie.com.au/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tatham.oddie.com.au</link>
	<description>Enter the Tatrix</description>
	<lastBuildDate>Sun, 21 Feb 2010 10:43:51 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='blog.tatham.oddie.com.au' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/0b67dd1962a151d7e1d78a45055c6b6d?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>Tatham Oddie</title>
		<link>http://blog.tatham.oddie.com.au</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.tatham.oddie.com.au/osd.xml" title="Tatham Oddie" />
	<atom:link rel='hub' href='http://blog.tatham.oddie.com.au/?pushpress=hub'/>
		<item>
		<title>Web Forms Model-View-Presenter on Hanselminutes</title>
		<link>http://blog.tatham.oddie.com.au/2010/02/21/web-forms-model-view-presenter-on-hanselminutes/</link>
		<comments>http://blog.tatham.oddie.com.au/2010/02/21/web-forms-model-view-presenter-on-hanselminutes/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 10:43:51 +0000</pubDate>
		<dc:creator>Tatham Oddie</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://tatham.wordpress.com/2010/02/21/web-forms-model-view-presenter-on-hanselminutes/</guid>
		<description><![CDATA[Over the last few months Damian Edwards and myself have been spending quite a bit of time building out a Model-View-Presenter framework for ASP.NET Web Forms.
Until now we’ve been pretty quiet about it all on our blogs because we were busy polishing off v1 and trying to get all the documentation in order. Nevertheless, the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tatham.oddie.com.au&blog=171289&post=420&subd=tatham&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Over the last few months <a href="http://damianedwards.com/">Damian Edwards</a> and myself have been spending quite a bit of time building out a <a href="http://webformsmvp.com">Model-View-Presenter framework for ASP.NET Web Forms</a>.</p>
<p>Until now we’ve been pretty quiet about it all on our blogs because we were busy polishing off v1 and trying to get all the documentation in order. Nevertheless, the word has definitely started to spread as Scott Hanselman interviewed me about the library on <a href="http://hanselminutes.com/default.aspx?showID=220">this week’s Hanselminutes episode</a>.</p>
<p><a href="http://hanselminutes.com/default.aspx?showID=220"><strong>Listen to the podcast</strong></a></p>
<p><a href="http://webformsmvp.com"><strong>Learn more about the library</strong></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tatham.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tatham.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tatham.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tatham.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tatham.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tatham.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tatham.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tatham.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tatham.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tatham.wordpress.com/420/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tatham.oddie.com.au&blog=171289&post=420&subd=tatham&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.tatham.oddie.com.au/2010/02/21/web-forms-model-view-presenter-on-hanselminutes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/459b8249e2b4dba8169774892cab0d48?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">tatham</media:title>
		</media:content>
	</item>
		<item>
		<title>Custom Code Analysis Rules in VS2010 (and how to make them run in FxCop and VS2008 too)</title>
		<link>http://blog.tatham.oddie.com.au/2010/01/06/custom-code-analysis-rules-in-vs2010-and-how-to-make-them-run-in-fxcop-and-vs2008-too/</link>
		<comments>http://blog.tatham.oddie.com.au/2010/01/06/custom-code-analysis-rules-in-vs2010-and-how-to-make-them-run-in-fxcop-and-vs2008-too/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 04:57:23 +0000</pubDate>
		<dc:creator>Tatham Oddie</dc:creator>
				<category><![CDATA[Improve Your Code]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://tatham.wordpress.com/?p=406</guid>
		<description><![CDATA[Back in 2002 Microsoft released FxCop, a static code analysis tool. At the time it was shipped as a separate product and received a bit of buzz. It used .NET reflection and a series of pre-defined rules to detect and report coding issues that wouldn’t normally be picked up by the compiler. Since this initial [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tatham.oddie.com.au&blog=171289&post=406&subd=tatham&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Back in 2002 Microsoft released FxCop, a static code analysis tool. At the time it was shipped as a separate product and received a bit of buzz. It used .NET reflection and a series of pre-defined rules to detect and report coding issues that wouldn’t normally be picked up by the compiler. Since this initial release, FxCop has undergone an amazing amount of work and become more mainstream with its integration into Visual Studio under the title of ‘Code Analysis’.</p>
<p>Recently I’ve been developing some custom extensions to FxCop – my own code analysis rules. While extremely powerful, this isn’t <u>yet</u> a fully documented or supported scenario. Until it is, this post shows you how to do it all.</p>
<h3>Why should we care?</h3>
<p>Lately I’ve been working on the <a href="http://webformsmvp.com">ASP.NET Web Forms Model-View-Presenter</a> framework. It’s not quite ready for launch yet, which is why I haven’t been blogging about it, but it is already in use by a number of high traffic websites. As more and more people have started to adopt the project in its relative infancy, documentation hasn’t been up to standard. To try and keep everybody in line I contemplated writing up some ‘best practices’ documentation but then figured that this probably wouldn’t get as much attention as it should and had a high chance of rapidly becoming stale.</p>
<p>Code analysis rules were the perfect solution. They would allow me to define a series of best practices for use of the library in a way that could be applied across multiple projects by the developers themselves. Code analysis rules are also great because they produce a simple task list of things to fix – something that appeals to developers and managers alike.</p>
<p>Over the course of developing these rules I’ve increasingly come to realise that custom rules are something that should be considered in any major project – even if it’s not a framework that will be redistributed. All projects (should) have some level of consistency in their architecture. The details of this are often enforced through good practice and code reviews, but from time to time things slip through. In the same way that we write unit tests to validate our work, I think we should be writing code analysis rules. Think of them like an “architectural validity test” or something.</p>
<h3>The Basics</h3>
<p>A quick note about versioning: First we’ll create some rules in VS2010, to be executed in VS2010. Later in the post we’ll look at how to compile these same rules in a way that makes them compatible with FxCop 1.36 (and thus VS2008). If you’re <u>only</u> targeting VS2008 then all the same concepts will apply but you’ll be able to skip a few steps.</p>
<ol>
<li>
<p>Start with a new class library project. Make sure you choose to target “.NET Framework 4”, even if the rest of your solution is targeting an earlier framework. Because we’re going to be loading these rules inside VS2010, and it uses .NET 4.0, we need to use it too. </p>
<p><img style="display:inline;border-width:0;" title="New Class Library using .NET Framework 4" border="0" alt="New Class Library using .NET Framework 4" src="http://tatham.files.wordpress.com/2010/01/1newproject.png?w=620&#038;h=199" width="620" height="199" />&#160;</p>
</li>
<li>Add references to <b>FxCopSdk.dll</b>, <b>Microsoft.Cci.dll</b> and <b>Microsoft.VisualStudio.CodeAnalysis.dll</b>. You’ll usually find these in <b>C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop</b>, or an equivalent location. Don’t worry about copying these libraries to a better location or anything – we’ll look at a smarter way of referencing them shortly. (<i>If you’re doing this in VS2008, you’ll need to download and install </i><a href="http://www.microsoft.com/downloads/details.aspx?familyid=9AEAA970-F281-4FB0-ABA1-D59D7ED09772&amp;displaylang=en"><i>FxCop 1.36</i></a><i> first and then find these references in that folder. Also, you’ll only need the first two.</i>) </li>
<li>
<p>Add a new XML file to your project called <b>Rules.xml</b>. This will be a manifest file that describes each of our individual rules. To get us started, paste in the following content:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;Rules FriendlyName=&quot;My Custom Rules&quot;&gt;
  &lt;Rule TypeName=&quot;AllTypeNamesShouldEndInFoo&quot; Category=&quot;CustomRules.Naming&quot; CheckId=&quot;CR1000&quot;&gt;
    &lt;Name&gt;All type names should end in 'Foo'&lt;/Name&gt;
    &lt;Description&gt;I like all of my types to end in 'Foo' so that I know they're a type.&lt;/Description&gt;
    &lt;Url&gt;http://foobar.com&lt;/Url&gt;
    &lt;Resolution&gt;The name of type {0} does not end with the suffix 'Foo'. Add the suffix to the type name.&lt;/Resolution&gt;
    &lt;MessageLevel Certainty=&quot;95&quot;&gt;Warning&lt;/MessageLevel&gt;
    &lt;FixCategories&gt;Breaking&lt;/FixCategories&gt;
    &lt;Email /&gt;
    &lt;Owner /&gt;
  &lt;/Rule&gt;
&lt;/Rules&gt;
</pre>
<p>This XML file is pretty self-explanatory, but there are a few things I should point out:</p>
<p>The type name needs to match the name of the class that we define the actual rule in, so make it appropriate (don’t use special characters, use <a href="http://blogs.msdn.com/brada/archive/2004/02/03/67024.aspx">Pascal casing</a>, etc).</p>
<p>The check id must be unique within the namespace of your rules, but really should be unique across the board. Microsoft uses the letters “CA” followed by a four digit number, and we use <a href="http://webformsmvp.codeplex.com/sourcecontrol/changeset/view/32839?projectName=webformsmvp#599994">a similar scheme</a> for <a href="http://webformsmvp.com/">Web Forms MVP</a>.</p>
<p>The resolution message is stored in the XML here, and not in your own code, but you want it to be as specific as possible so that the developer on the receiving end of it knows exactly what they need to do. Use it like a formatting string – you’ll soon see that it works really nicely.</p>
</li>
<li>
<p>Go to the properties for the XML file and change the Build Action to <b>EmbeddedResource</b> so that it gets compiled into our DLL. </p>
<p><img style="display:inline;border-width:0;" title="Build Action: Embedded Resource" border="0" alt="Build Action: Embedded Resource" src="http://tatham.files.wordpress.com/2010/01/2embeddedresource.png?w=381&#038;h=253" width="381" height="253" /> </p>
</li>
<li>
<p>Create a class called <b>BaseRule</b> and paste in the following code:</p>
<pre class="brush: csharp;">
using Microsoft.FxCop.Sdk;

public abstract class BaseRule : BaseIntrospectionRule
{
    protected BaseRule(string name)
        : base(

            // The name of the rule (must match exactly to an entry
            // in the manifest XML)
            name,

            // The name of the manifest XML file, qualified with the
            // namespace and missing the extension
            typeof(BaseRule).Assembly.GetName().Name + &quot;.Rules&quot;,

            // The assembly to find the manifest XML in
            typeof(BaseRule).Assembly)
    {
    }
}
</pre>
<p>There are three pieces of information we’re passing into the base constructor here. The first is the type name of the rule which the framework will use to find the corresponding entry in the manifest, the second is the namespace qualified resource name of the manifest file itself and the last is the assembly that the manifest is stored in. I like to create this base class because the last two arguments will be the same for all of your rules and it gets ugly repeating them at the top of each rule.</p>
</li>
<li>
<p>Create a class called <b>AllTypeNamesShouldEndInFoo</b> and paste in the following stub code:</p>
<pre class="brush: csharp;">
using Microsoft.FxCop.Sdk;
using Microsoft.VisualStudio.CodeAnalysis.Extensibility;

public class AllTypeNamesShouldEndInFoo : BaseRule
{
    public AllTypeNamesShouldEndInFoo()
        : base(&quot;AllTypeNamesShouldEndInFoo&quot;)
    {
    }
}
</pre>
</li>
</ol>
<p>That’s all of the boilerplate code in place. Before we start writing the actual rule, let’s take a brief detour to the world of introspection.</p>
<h3>Um &#8230; ‘introspection’?</h3>
<p>The first version of FxCop used basic .NET reflection to weave its magic. This approach is relatively simple, familiar to most developers and was a quick-to-market solution for them. As FxCop grew, this approach couldn’t scale though. Reflection has two main problems: First and foremost, it only lets you inspect the signatures of types and members – there’s no way to look inside a method and see what other methods it’s calling or to identify bad control flows. Reflection also inherits a major restriction from the underlying framework – once loaded into an app domain, and assembly can’t be unloaded. This restriction wreaks havoc in scenarios where developers want to be able to rapidly rerun the tests; having to restart FxCop every time isn’t the most glamorous of development experiences.</p>
<p>At this point we could fall back to inspecting the original source code, but that comes with a whole bunch of parsing nightmares and ultimately ties us back to a particular language. <a href="http://en.wikipedia.org/wiki/MSIL">CIL</a> is where we want to be.</p>
<p>Later versions of FxCop started using an <i>introspection</i> engine. This provided a fundamentally different experience, light-years ahead of what reflection could provide. The introspection engine performs all of its own CIL parsing which means that it can be pointed at any .NET assembly without having to load that assembly into the runtime. Code can be inspected without ever having the chance of being executed. The same assembly can be reloaded as many times as we want. Better yet, we can explore from the assembly level right down to individual opcodes and control structures through a unified API.</p>
<p>Jason Kresowaty has published <a href="http://www.binarycoder.net/fxcop/html/introspection_code_model.html">a nice write up of the introspection engine</a>. Even cooler yet, he has released a tool called <a href="http://www.binarycoder.net/fxcop/html/introspector.html">Introspector</a> which allows us to visualise the object graph that the introspection engine gives us. I highly recommend that you download it before you get into any serious rules development.</p>
<p><img style="display:inline;border-width:0;" title="Introspector" border="0" alt="Introspector" src="http://tatham.files.wordpress.com/2010/01/3introspector.png?w=364&#038;h=371" width="364" height="371" /> </p>
<h3>Back to our rule&#8230;</h3>
<p>Now that we know some of the basics of introspection, we’re ready to start coding our own rule. As a reminder, this is what we have so far:</p>
<pre class="brush: csharp;">
using Microsoft.FxCop.Sdk;
using Microsoft.VisualStudio.CodeAnalysis.Extensibility;

public class AllTypeNamesShouldEndInFoo : BaseRule
{
    public AllTypeNamesShouldEndInFoo()
        : base(&quot;AllTypeNamesShouldEndInFoo&quot;)
    {
    }
}
</pre>
<p>The FxCop runtime manages the process of ‘walking’ the assembly for us. It will visit every node that it needs to, but no more, and it’ll do it across multiple threads. All we need to do is tell the runtime which nodes we’re interested in. To do this, we override one of the many <b>Check</b> methods.</p>
<p>As much as possible, use the most specific override that you can as this will give FxCop a better idea of what you’re actually looking at and thus provide better feedback to the end user. For example, if you want to look at method names don’t override <b>Check(TypeNode)</b> and enumerate the methods yourself because any violations you raise will be raised against the overall type. Instead, override <b>Check(Member member)</b>.</p>
<p>In our scenario, because we want to check type names, we’ll override <b>Check(TypeNode type)</b>.</p>
<p>The actual code for this rule is quite simple:</p>
<pre class="brush: csharp;">
public override ProblemCollection Check(TypeNode type)
{
    if (!type.Name.Name.EndsWith(&quot;Foo&quot;, StringComparison.Ordinal))
    {
        var resolution = GetResolution(type.Name.Name);
        var problem = new Problem(resolution, type)
                          {
                              Certainty = 100,
                              FixCategory = FixCategories.Breaking,
                              MessageLevel = MessageLevel.Warning
                          };
        Problems.Add(problem);
    }

    return Problems;
}
</pre>
<p>All we’re doing here is checking the name of the type, and then adding a problem to a collection on the base type. The <b>GetResolution</b> method acts like <b>string.Format</b> and takes an array of parameters then formats them into the resolution text we defined in the XML file.</p>
<p>The second argument that we pass to the <b>Problem</b> constructor is the introspection node that the problem relates to. In this case it’s just the type itself, but if we were doing our own enumeration then we would pass the most specific node possible here so that FxCop could return the most accurate source reference possible to the end user.</p>
<h3>Let’s start ‘er up.</h3>
<p>At the time of writing, the latest standalone version of FxCop is 1.36 which still targets .NET 2.0 – 3.5. Because we’ve written our rule in .NET 4.0, our only option is to test it within Visual Studio. Luckily, that’s not as hard as it sounds. (<i>If you’re writing your rules in VS2008, jump over this section.</i>)</p>
<ol>
<li>Create another class library in your solution called TestLibrary. We won’t put any real code in here – we’re just going to use it as the library to execute our rules against. </li>
<li>
<p>Add a new Code Analysis Rule Set file to the project: </p>
<p><img style="display:inline;border-width:0;" title="New Code Analysis Rule Set" border="0" alt="New Code Analysis Rule Set" src="http://tatham.files.wordpress.com/2010/01/4ruleset.png?w=587&#038;h=280" width="587" height="280" /> </p>
</li>
<li>
<p>When the file opens in the designer you’ll see a list of all the built-in rules. Because custom rules aren’t really supported yet, there’s no nice way of adding our own rules into this list.</p>
<p><img style="display:inline;border-width:0;" title="Default Rules" border="0" alt="Default Rules" src="http://tatham.files.wordpress.com/2010/01/5defaultrules.png?w=707&#038;h=335" width="707" height="335" /> </p>
</li>
<li>
<p>In Solution Explorer, right click on the .ruleset file, choose <b>Open With</b> and select <b>XML Editor</b> from the options. This will show you the raw contents of the file, which is currently pretty boring. To point Visual Studio in the direction of your custom rules, you then add a series of hint paths. </p>
<p>This is what my rule set XML looks like:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;RuleSet Name=&quot;New Rule Set&quot; Description=&quot;&quot; ToolsVersion=&quot;10.0&quot;&gt;
  &lt;RuleHintPaths&gt;
    &lt;Path&gt;C:\Temp\CARules\BlogDemo\BlogDemo.CodeAnalysisRules\bin\Debug&lt;/Path&gt;
  &lt;/RuleHintPaths&gt;
&lt;/RuleSet&gt;
</pre>
<p>Hint paths can be absolute, or relative to the location of the rule set file. They should point at the exact folder that your compiled rules sit in. Because Visual Studio fails silently if it can’t load a rule, <u>I prefer to start with an absolute folder path first</u>, then change it to a relative path once everything is working.</p>
</li>
<li>
<p><u>Make sure you have compiled your rules project</u>, then go back to Solution Explorer, right click on the .ruleset file, choose <b>Open With</b> and select <b>Code Analysis Rule Set Editor</b>.</p>
<p>(<i>If you have file locking issues, close Visual Studio, delete all of your <b>bin</b> folders, reopen the solution, build the rules project, then attempt to open the Code Analysis Rule Set Editor again.)</i></p>
</li>
</ol>
<p>Now, you should see your custom rule loaded into the list:</p>
<p><img style="display:inline;border-width:0;" title="6CustomRules" border="0" alt="6CustomRules" src="http://tatham.files.wordpress.com/2010/01/6customrules.png?w=707&#038;h=335" width="707" height="335" /> </p>
<p>Running the rule is now easy. Open the project properties for your test library project, go to the Code Analysis tab, enable Code Analysis and select our new rule set:</p>
<p><img style="display:inline;border-width:0;" title="7EnableCodeAnalysis" border="0" alt="7EnableCodeAnalysis" src="http://tatham.files.wordpress.com/2010/01/7enablecodeanalysis.png?w=704&#038;h=490" width="704" height="490" /> </p>
<p>Now when we build the project, the output from our new rule will appear in the Errors List just like any of the default rules:</p>
<p><img style="display:inline;border-width:0;" title="8ErrorList" border="0" alt="8ErrorList" src="http://tatham.files.wordpress.com/2010/01/8errorlist.png?w=707&#038;h=151" width="707" height="151" /> </p>
<h3>A Bit of Clean-up</h3>
<p>Back when we first created the project file for our rules we referenced a couple of DLLs from a system location. This isn’t very maintainable, particularly in a team environment, so let’s clean that up quickly.</p>
<ol>
<li>Right click on the rules project and select “Unload Project” </li>
<li>Right click on the rules project again and select “Edit .csproj” – this will show you the raw XML definition for the project </li>
<li>
<p>Find these three references:</p>
<pre class="brush: xml;">
&lt;Reference Include=&quot;FxCopSdk&quot;&gt;
  &lt;HintPath&gt;..\..\..\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\FxCopSdk.dll&lt;/HintPath&gt;
  &lt;Private&gt;False&lt;/Private&gt;
&lt;/Reference&gt;
&lt;Reference Include=&quot;Microsoft.Cci&quot;&gt;
  &lt;HintPath&gt;..\..\..\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\Microsoft.Cci.dll&lt;/HintPath&gt;
  &lt;Private&gt;False&lt;/Private&gt;
&lt;/Reference&gt;
&lt;Reference Include=&quot;Microsoft.VisualStudio.CodeAnalysis, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL&quot;&gt;
  &lt;SpecificVersion&gt;False&lt;/SpecificVersion&gt;
  &lt;HintPath&gt;..\..\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\Microsoft.VisualStudio.CodeAnalysis.dll&lt;/HintPath&gt;
  &lt;Private&gt;True&lt;/Private&gt;
&lt;/Reference&gt;
</pre>
<p>And replace them with this:</p>
<pre class="brush: xml;">
&lt;Reference Include=&quot;FxCopSdk&quot;&gt;
  &lt;HintPath&gt;$(CodeAnalysisPath)\FxCopSdk.dll&lt;/HintPath&gt;
  &lt;Private&gt;False&lt;/Private&gt;
&lt;/Reference&gt;
&lt;Reference Include=&quot;Microsoft.Cci&quot;&gt;
  &lt;HintPath&gt;$(CodeAnalysisPath)\Microsoft.Cci.dll&lt;/HintPath&gt;
  &lt;Private&gt;False&lt;/Private&gt;
&lt;/Reference&gt;
&lt;Reference Include=&quot;Microsoft.VisualStudio.CodeAnalysis&quot;&gt;
  &lt;HintPath&gt;$(CodeAnalysisPath)\Microsoft.VisualStudio.CodeAnalysis.dll&lt;/HintPath&gt;
  &lt;Private&gt;False&lt;/Private&gt;
&lt;/Reference&gt;
</pre>
<p>The build system populates the $(CodeAnalysisPath) variable for us automatically. This way, our references will be valid on every developer’s machine.</p>
</li>
<li>Save and close the file, then right click the project and select “Reload Project” </li>
</ol>
<h3>Do the shuffle. The two-step, multi-framework shuffle&#8230;</h3>
<p>For <a href="http://webformsmvp.com/">Web Forms MVP</a> we want to support users on both VS2008 and VS2010. The work we’ve done so far in this post is all exclusively targeted towards VS2010 and <i>not</i> compatible with VS2008 or FxCop 1.36.</p>
<p>To make the compiled rules compatible with both IDEs we’ll need to compile two different versions of it. The VS2008 version will use .NET 3.5 and only two references while the VS2010 version will use .NET 4 and a third reference, <b>Microsoft.VisualStudio.CodeAnalysis</b>.</p>
<ol>
<li>Right click on the rules project and select “Unload Project” </li>
<li>Right click on the rules project again and select “Edit .csproj” – this will show you the raw XML definition for the project </li>
<li>
<p>Find both your Debug and Release property groups and add a DEV10 constant to each:</p>
<pre class="brush: xml; highlight: [3,8];">
&lt;PropertyGroup Condition=&quot; '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' &quot;&gt;
  ...
  &lt;DefineConstants&gt;TRACE;DEBUG;CODE_ANALYSIS;DEV10&lt;/DefineConstants&gt;
  ...
&lt;/PropertyGroup&gt;
&lt;PropertyGroup Condition=&quot; '$(Configuration)|$(Platform)' == 'Release|AnyCPU' &quot;&gt;
  ...
  &lt;DefineConstants&gt;TRACE;DEV10&lt;/DefineConstants&gt;
  ...
&lt;/PropertyGroup&gt;
</pre>
</li>
<li>
<p>Find the <b>Microsoft.VisualStudio.CodeAnalysis</b> reference and make it conditional based on the framework version being compiled against:</p>
<pre class="brush: xml; highlight: [1];">
&lt;Reference Include=&quot;Microsoft.VisualStudio.CodeAnalysis&quot; Condition=&quot; '$(TargetFrameworkVersion)' == 'v4.0' &quot;&gt;
  &lt;HintPath&gt;$(CodeAnalysisPath)\Microsoft.VisualStudio.CodeAnalysis.dll&lt;/HintPath&gt;
  &lt;Private&gt;False&lt;/Private&gt;
&lt;/Reference&gt;
</pre>
</li>
<li>Save and close the file, then right click the project and select “Reload Project” </li>
<li>
<p>Go to <strong>AllTypeNamesShouldEndInFoo.cs</strong> and wrap the using statement for <b>Microsoft.VisualStudio.CodeAnalysis.Extensibility</b> in an <b>#if</b> construct like so:</p>
<pre class="brush: csharp; highlight: [3,5];">
using System;
using Microsoft.FxCop.Sdk;
#if DEV10
    using Microsoft.VisualStudio.CodeAnalysis.Extensibility;
#endif
</pre>
</li>
<li>Make sure that your project still compiles with VS2010 </li>
</ol>
<p>At this point our project is still only building for VS2010 but it now contains all of the hook points we need to perform a second build for VS2008. The reference to <b>Microsoft.VisualStudio.CodeAnalysis.dll</b> will only be included if we’re building against .NET 4 and the using statements will only be compiled if the <b>DEV10</b> compilation constant is present.</p>
<p>Normally, we would build the project using a simple call to MSBuild (which is exactly what VS2010 does under the covers):</p>
<pre class="brush: plain;">
MSBuild &quot;BlogDemo.CodeAnalysisRules.csproj&quot; /p:Configuration=Release /maxcpucount
</pre>
<p>To compile the FxCop 1.36 version, we just pass some extra arguments:</p>
<pre class="brush: plain;">
MSBuild  BlogDemo.CodeAnalysisRules.csproj &quot; /p:Configuration=Release /maxcpucount /p:CodeAnalysisPath=&quot;..\Dependencies\FxCop136\&quot; /p:DefineConstants=&quot;&quot; /p:TargetFrameworkVersion=&quot;v3.5&quot;
</pre>
<p>The <b>CodeAnalysisPath</b> parameter is normally supplied by MSBuild, but we are now overriding it with the location of the FxCop 1.36 SDK. We’re also overriding <b>TargetFrameworkVersion</b>.</p>
<p>Of course, there are nicer ways to script the build process using technologies like PowerShell. The ZIP file below contains a nice little <b>Build-CARules.ps1</b> which you can use as a template.</p>
<h3>The Resources</h3>
<p>Download all of the sample code from this blog post and a PowerShell build script here:</p>
</p>
<p>
<a href="http://tath.am/files/20100106-CodeAnalysisRulesBlogDemo.zip"><img src="http://tatham.files.wordpress.com/2010/01/download.png?w=250&#038;h=52" alt="Download CodeAnalysisRulesBlogDemo.zip" title="DownloadCodeAnalysisRulesBlogDemo" width="250" height="52" class="alignnone size-full wp-image-413" border="0" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tatham.wordpress.com/406/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tatham.wordpress.com/406/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tatham.wordpress.com/406/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tatham.wordpress.com/406/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tatham.wordpress.com/406/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tatham.wordpress.com/406/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tatham.wordpress.com/406/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tatham.wordpress.com/406/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tatham.wordpress.com/406/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tatham.wordpress.com/406/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tatham.oddie.com.au&blog=171289&post=406&subd=tatham&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.tatham.oddie.com.au/2010/01/06/custom-code-analysis-rules-in-vs2010-and-how-to-make-them-run-in-fxcop-and-vs2008-too/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/459b8249e2b4dba8169774892cab0d48?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">tatham</media:title>
		</media:content>

		<media:content url="http://tatham.files.wordpress.com/2010/01/1newproject.png" medium="image">
			<media:title type="html">New Class Library using .NET Framework 4</media:title>
		</media:content>

		<media:content url="http://tatham.files.wordpress.com/2010/01/2embeddedresource.png" medium="image">
			<media:title type="html">Build Action: Embedded Resource</media:title>
		</media:content>

		<media:content url="http://tatham.files.wordpress.com/2010/01/3introspector.png" medium="image">
			<media:title type="html">Introspector</media:title>
		</media:content>

		<media:content url="http://tatham.files.wordpress.com/2010/01/4ruleset.png" medium="image">
			<media:title type="html">New Code Analysis Rule Set</media:title>
		</media:content>

		<media:content url="http://tatham.files.wordpress.com/2010/01/5defaultrules.png" medium="image">
			<media:title type="html">Default Rules</media:title>
		</media:content>

		<media:content url="http://tatham.files.wordpress.com/2010/01/6customrules.png" medium="image">
			<media:title type="html">6CustomRules</media:title>
		</media:content>

		<media:content url="http://tatham.files.wordpress.com/2010/01/7enablecodeanalysis.png" medium="image">
			<media:title type="html">7EnableCodeAnalysis</media:title>
		</media:content>

		<media:content url="http://tatham.files.wordpress.com/2010/01/8errorlist.png" medium="image">
			<media:title type="html">8ErrorList</media:title>
		</media:content>

		<media:content url="http://tatham.files.wordpress.com/2010/01/download.png" medium="image">
			<media:title type="html">DownloadCodeAnalysisRulesBlogDemo</media:title>
		</media:content>
	</item>
		<item>
		<title>I work on the web.</title>
		<link>http://blog.tatham.oddie.com.au/2009/09/25/i-work-on-the-web/</link>
		<comments>http://blog.tatham.oddie.com.au/2009/09/25/i-work-on-the-web/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 04:08:46 +0000</pubDate>
		<dc:creator>Tatham Oddie</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tatham.wordpress.com/2009/09/25/i-work-on-the-web/</guid>
		<description><![CDATA[Readify’s CTO Mitch Denny just announced Damian and myself as the first two Readify staff to receive the new title of “Technical Specialist”. This is an additional title to represent technical focus beyond our standard consulting commitments. Over the coming weeks, this will be awarded in a number of key technology areas. Obviously, for Damian and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tatham.oddie.com.au&blog=171289&post=388&subd=tatham&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.readify.net">Readify’s</a> CTO <a href="http://notgartner.com">Mitch Denny</a> just announced <a href="http://damianedwards.com">Damian</a> and myself as the first two Readify staff to receive the new title of “Technical Specialist”. This is an additional title to represent technical focus beyond our standard consulting commitments. Over the coming weeks, this will be awarded in a number of key technology areas. Obviously, for Damian and myself, it’s the web. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>As part of the position we needed to do a bit of a refresh on our consulting profiles, a component of which is a blurb about why we work in the industry. Having just written mine, I felt like sharing it:</p>
<blockquote><p>The web was never a platform I explicitly sought out; it was more so somewhere I ended up, but I ended up here for a reason. The shear breadth and power of the web, from both technical and business perspectives, made it a natural fit as I developed my career and skill sets.</p>
<p>I’ve always been fascinated by how a relatively simple set of building blocks designed through the 70s and 80s now underpin so much of what we do today. Video calling might look all fancy and futuristic, but it’s still sitting on much of that same technology. It’s this ability to foster evolution and innovation in an open, neutral and (mostly) democratic way that makes the web both possible and exciting.</p>
<p>Mass organic adoption of the web has today given us a heterogeneous environment of networks, devices and software clients that can be quite accurately described as somewhat hostile. Navigating these challenges to deliver a robust and compelling solution, while also seeking to drive the web forward, is what I do as a web specialist.</p>
<p>Microsoft’s early forays into web development were designed to make it an easy transition for their existing community of developers. This approach has resulted in a generation of developers who work on the web without necessarily being fully aware of its scope or potential. Microsoft’s current push is to now bring these developers across to the next iteration of the web. Engaging these audiences and encouraging them to that take that next step is a key component of what I do as an active community member.</p>
<p>In an ever increasingly connected world, now is the time to work on the web.</p></blockquote>
<p>Why do you <a href="http://iworkontheweb.com/">work on the web</a>?</p>
<p>(While you’re thinking about it, check out <a href="http://iworkontheweb.com/">iworkontheweb.com</a>)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tatham.wordpress.com/388/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tatham.wordpress.com/388/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tatham.wordpress.com/388/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tatham.wordpress.com/388/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tatham.wordpress.com/388/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tatham.wordpress.com/388/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tatham.wordpress.com/388/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tatham.wordpress.com/388/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tatham.wordpress.com/388/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tatham.wordpress.com/388/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tatham.oddie.com.au&blog=171289&post=388&subd=tatham&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.tatham.oddie.com.au/2009/09/25/i-work-on-the-web/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/459b8249e2b4dba8169774892cab0d48?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">tatham</media:title>
		</media:content>
	</item>
		<item>
		<title>Missed TechEd Australia? Get the content anyway.</title>
		<link>http://blog.tatham.oddie.com.au/2009/09/22/missed-teched-australia-get-the-content-anyway/</link>
		<comments>http://blog.tatham.oddie.com.au/2009/09/22/missed-teched-australia-get-the-content-anyway/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 23:52:32 +0000</pubDate>
		<dc:creator>Tatham Oddie</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tatham.wordpress.com/2009/09/22/missed-teched-australia-get-the-content-anyway/</guid>
		<description><![CDATA[Close on the heels of TechEd Australia, Readify have announced their latest Dev Day event. This time, we’ve also tweaked the structure a little bit so that instead of having two tracks at the same time we’ll be running a morning track and an afternoon track. This way you get to see it all, or [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tatham.oddie.com.au&blog=171289&post=387&subd=tatham&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Close on the heels of TechEd Australia, <a href="http://www.readify.net">Readify</a> have announced their latest Dev Day event. This time, we’ve also tweaked the structure a little bit so that instead of having two tracks at the same time we’ll be running a morning track and an afternoon track. This way you get to see it all, or just pop in for the half day if you want.</p>
<p><a href="http://richardsbraindump.blogspot.com/">Richard Banks</a> will be presenting in the morning on <strong>Software Quality and Application Lifecycle Management</strong>, split into:</p>
<ul>
<li>Gathering Quality Requirements for Agile Development Teams, and an </li>
<li>Introduction to Visual Studio Team System 2010. </li>
</ul>
<p>In the afternoon, I’ll be covering <strong>Building for the Web with .NET</strong> through three different presentations:</p>
<ul>
<li>Building Fast, Standards Compliant ASP.NET Websites, </li>
<li>ASP.NET MVC: Building for the web, and an </li>
<li>Introduction to the ASP.NET Web Forms Model-View-Presenter framework. </li>
</ul>
<p>For my talks, you can find some teasers between my <a href="http://blog.tatham.oddie.com.au/2009/09/14/video-building-fast-public-websites/">last</a> <a href="http://blog.tatham.oddie.com.au/2009/09/14/video-asp-net-mvc-vs-asp-net-webforms-will-webforms-be-replaced-by-mvc/">two</a> blog posts and <a href="http://webformsmvp.codeplex.com/">CodePlex</a>.</p>
<p>To see it all, you’ll just have to come along though. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>More info at: <a title="http://readify.net/training-and-events/rdn-dev-days/" href="http://readify.net/training-and-events/rdn-dev-days/">http://readify.net/training-and-events/rdn-dev-days/</a></p>
<p>See you there!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tatham.wordpress.com/387/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tatham.wordpress.com/387/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tatham.wordpress.com/387/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tatham.wordpress.com/387/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tatham.wordpress.com/387/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tatham.wordpress.com/387/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tatham.wordpress.com/387/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tatham.wordpress.com/387/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tatham.wordpress.com/387/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tatham.wordpress.com/387/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tatham.oddie.com.au&blog=171289&post=387&subd=tatham&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.tatham.oddie.com.au/2009/09/22/missed-teched-australia-get-the-content-anyway/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/459b8249e2b4dba8169774892cab0d48?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">tatham</media:title>
		</media:content>
	</item>
		<item>
		<title>Video: Building Fast, Public Websites</title>
		<link>http://blog.tatham.oddie.com.au/2009/09/14/video-building-fast-public-websites/</link>
		<comments>http://blog.tatham.oddie.com.au/2009/09/14/video-building-fast-public-websites/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 11:04:53 +0000</pubDate>
		<dc:creator>Tatham Oddie</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://tatham.wordpress.com/2009/09/14/video-building-fast-public-websites/</guid>
		<description><![CDATA[Following up from my last post about the ASP.NET MVC vs ASP.NET WebForms debate, we’ve had a second TechTalk posted, also from TechEd Australia. In this video, Michael Kordahi, Damian Edwards and I sat down to discuss building fast, public websites. It was a bit of a teaser for our breakout session at the conference, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tatham.oddie.com.au&blog=171289&post=382&subd=tatham&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Following up from my last post about <a href="http://blog.tatham.oddie.com.au/2009/09/14/video-asp-net-mvc-vs-asp-net-webforms-will-webforms-be-replaced-by-mvc/">the ASP.NET MVC vs ASP.NET WebForms debate</a>, we’ve had a second TechTalk posted, also from TechEd Australia. In this video, <a href="http://delicategeniusblog.com/">Michael Kordahi</a>, <a href="http://damianedwards.com/">Damian Edwards</a> and I sat down to discuss building fast, public websites. It was a bit of a teaser for our breakout session at the conference, which will be available online as a screencast in the next week or two.</p>
<p>If you’re interested in learning more about building large public websites on ASP.NET, remember that the full video from <a href="http://blog.tatham.oddie.com.au/2009/06/18/video-building-great-standards-based-websites-for-the-big-wide-world-with-asp-net-4-0/">our recent REMIX session</a> is still available online too.</p>
<p align="center"><a title="Building Fast, Public Websites" href="http://www.msteched.com/online/view.aspx?tid=3d0d06c3-46f5-4f42-878f-3d20bf44b906"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;margin:0 0 0 50px;" title="Building Fast, Public Websites" border="0" alt="Building Fast, Public Websites" src="http://tatham.files.wordpress.com/2009/09/fastpublicposter.png?w=364&#038;h=205" width="364" height="205" /></a> </p>
<p align="center"><a href="http://www.msteched.com/online/view.aspx?tid=3d0d06c3-46f5-4f42-878f-3d20bf44b906">Watch Online</a> or <a href="http://e.msteched.com/public/au/TTK113.wmv">Download</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tatham.wordpress.com/382/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tatham.wordpress.com/382/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tatham.wordpress.com/382/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tatham.wordpress.com/382/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tatham.wordpress.com/382/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tatham.wordpress.com/382/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tatham.wordpress.com/382/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tatham.wordpress.com/382/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tatham.wordpress.com/382/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tatham.wordpress.com/382/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tatham.oddie.com.au&blog=171289&post=382&subd=tatham&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.tatham.oddie.com.au/2009/09/14/video-building-fast-public-websites/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
<enclosure url="http://e.msteched.com/public/au/TTK113.wmv" length="39882863" type="video/x-ms-wmv" />
	
		<media:content url="http://0.gravatar.com/avatar/459b8249e2b4dba8169774892cab0d48?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">tatham</media:title>
		</media:content>

		<media:content url="http://tatham.files.wordpress.com/2009/09/fastpublicposter.png" medium="image">
			<media:title type="html">Building Fast, Public Websites</media:title>
		</media:content>
	</item>
		<item>
		<title>Video: ASP.NET MVC vs ASP.NET WebForms &#8211; Will WebForms be replaced by MVC?</title>
		<link>http://blog.tatham.oddie.com.au/2009/09/14/video-asp-net-mvc-vs-asp-net-webforms-will-webforms-be-replaced-by-mvc/</link>
		<comments>http://blog.tatham.oddie.com.au/2009/09/14/video-asp-net-mvc-vs-asp-net-webforms-will-webforms-be-replaced-by-mvc/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 10:52:24 +0000</pubDate>
		<dc:creator>Tatham Oddie</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://tatham.wordpress.com/2009/09/14/video-asp-net-mvc-vs-asp-net-webforms-will-webforms-be-replaced-by-mvc/</guid>
		<description><![CDATA[At the recent TechEd Australia conference, Paul Glavich, Damian Edwards and myself sat down to discuss what we thought about the current MVC vs WebForms debate. Our TechTalk has now been posted on the TechEd Online site, and available for anyone to watch.
Check it out, and feel free to continue the debate with any of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tatham.oddie.com.au&blog=171289&post=379&subd=tatham&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>At the recent TechEd Australia conference, <a href="http://weblogs.asp.net/pglavich/">Paul Glavich</a>, <a href="http://damianedwards.com/">Damian Edwards</a> and myself sat down to discuss what we thought about the current MVC vs WebForms debate. Our TechTalk has now been posted on the TechEd Online site, and available for anyone to watch.</p>
<p>Check it out, and feel free to continue the debate with any of us. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p align="center"><a title="ASP.NET MVC vs ASP.NET Webforms - will webforms be replaced by MVC?" href="http://www.msteched.com/online/view.aspx?tid=f97393ad-ba67-4c1f-9676-b8eb1d35afe8"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;margin:0;" title="ASP.NET MVC vs ASP.NET WebForms – Will WebForms be replaced by MVC?" border="0" alt="ASP.NET MVC vs ASP.NET WebForms – Will WebForms be replaced by MVC?" src="http://tatham.files.wordpress.com/2009/09/mvcposter.png?w=364&#038;h=205" width="364" height="205" /></a>&#160;</p>
<p align="center"><a href="http://www.msteched.com/online/view.aspx?tid=f97393ad-ba67-4c1f-9676-b8eb1d35afe8">Watch Online</a> or <a href="http://e.msteched.com/public/au/TTK117.wmv">Download</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tatham.wordpress.com/379/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tatham.wordpress.com/379/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tatham.wordpress.com/379/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tatham.wordpress.com/379/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tatham.wordpress.com/379/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tatham.wordpress.com/379/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tatham.wordpress.com/379/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tatham.wordpress.com/379/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tatham.wordpress.com/379/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tatham.wordpress.com/379/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tatham.oddie.com.au&blog=171289&post=379&subd=tatham&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.tatham.oddie.com.au/2009/09/14/video-asp-net-mvc-vs-asp-net-webforms-will-webforms-be-replaced-by-mvc/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
<enclosure url="http://e.msteched.com/public/au/TTK117.wmv" length="30591011" type="video/x-ms-wmv" />
	
		<media:content url="http://0.gravatar.com/avatar/459b8249e2b4dba8169774892cab0d48?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">tatham</media:title>
		</media:content>

		<media:content url="http://tatham.files.wordpress.com/2009/09/mvcposter.png" medium="image">
			<media:title type="html">ASP.NET MVC vs ASP.NET WebForms – Will WebForms be replaced by MVC?</media:title>
		</media:content>
	</item>
		<item>
		<title>Announcing: OpenSearch on ASP.NET made super easy with the OpenSearch Toolkit</title>
		<link>http://blog.tatham.oddie.com.au/2009/07/19/announcing-opensearch-on-asp-net-made-super-easy-with-the-opensearch-toolkit/</link>
		<comments>http://blog.tatham.oddie.com.au/2009/07/19/announcing-opensearch-on-asp-net-made-super-easy-with-the-opensearch-toolkit/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 12:35:00 +0000</pubDate>
		<dc:creator>Tatham Oddie</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tatham.wordpress.com/?p=364</guid>
		<description><![CDATA[OpenSearch is a technology that already has widespread support across the web and is now getting even more relevant with Internet Explorer 8’s Visual Search feature and the Federated Search feature in the upcoming Windows 7 release.
Recently I blogged about some work I’d been doing with OpenSearch and how frustrating the whole process was. By [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tatham.oddie.com.au&blog=171289&post=364&subd=tatham&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>OpenSearch is a technology that already has widespread support across the web and is now getting even more relevant with Internet Explorer 8’s Visual Search feature and the Federated Search feature in the upcoming Windows 7 release.</p>
<p>Recently <a href="http://blog.tatham.oddie.com.au/2009/06/06/released-opensearch-validator/">I blogged about some work I’d been doing with OpenSearch</a> and how frustrating the whole process was. By the time you build feeds for IE8, Firefox and Windows 7 you’ve touched on “standards” documented by Amazon, Yahoo, Mozilla and Microsoft. Good luck tracking down all that info and working out the discrepancies!</p>
<p>As a first step to making this easier, I released the <a href="http://opensearchvalidator.com/">OpenSearch Validator</a> so we had a quick way to track down all the potential issues and get a clear indication of whether our OpenSearch implementation was going to work in all environments we wanted it to. I also <a href="http://opensearchvalidator.codeplex.com/">released the source code for this</a> on CodePlex so that you can run it in your internal dev environments or even integrate it into your build process.</p>
<p>Now it’s time to make it even easier. <a href="http://ducas.wordpress.com/">Ducas Francis</a>, one of the other members of my team, took on the job of building out our JSON feed for Firefox as well as our RSS feed for Windows 7 Federated Search. More formats, more fiddly serialization code. Following this, he started <a href="http://opensearchtoolkit.codeplex.com/">the OpenSearch Toolkit</a>; an open source, drop-in toolkit for ASP.NET developers to use when they want to offer OpenSearch.</p>
<p>Today marks our first release.</p>
<h2>Implementing OpenSearch</h2>
<p>First up, <a href="http://opensearchtoolkit.codeplex.com/Release/ProjectReleases.aspx">download the latest release</a> of the project from CodePlex and add it to your project references:</p>
<p><img style="display:inline;border-width:0;margin:0 0 0 50px;" title="Reference" border="0" alt="Reference" src="http://tatham.files.wordpress.com/2009/07/reference.png?w=250&#038;h=161" width="250" height="161" /> </p>
</p>
<p>Next, add a new Generic Handler to your project called <strong>OpenSearch.ashx</strong>:</p>
<p><img style="display:inline;border-width:0;margin:0 0 0 50px;" title="GenericHandler" border="0" alt="GenericHandler" src="http://tatham.files.wordpress.com/2009/07/generichandler2.png?w=515&#038;h=414" width="515" height="414" /> </p>
<p>In the code behind for the handler (OpenSearch.ashx.cs), remove the autogenerated code and change the base class to <strong>OpenSearchHandler</strong>:</p>
<p><img style="display:inline;border-width:0;margin:0 0 0 50px;" title="BaseClass" border="0" alt="BaseClass" src="http://tatham.files.wordpress.com/2009/07/baseclass.png?w=416&#038;h=166" width="416" height="166" /> </p>
<p>Now, just start implementing the abstract properties and methods on the base class.</p>
<p>The first one you’ll want to implement is the <strong>Description</strong> property. This returns the basic meta data about your provider that will be shown when users choose to add it to their browser’s list of search providers. You also need to specify the <strong>SearchPathTemplate</strong> which is a format string that the OpenSearch Toolkit will use to generate links to your site’s search page.</p>
<p><img style="display:inline;border-width:0;margin:0 0 0 50px;" title="Description" border="0" alt="Description" src="http://tatham.files.wordpress.com/2009/07/description1.png?w=514&#038;h=198" width="514" height="198" /> </p>
<p>Next, implement each of the data methods. <strong>GetResults</strong> is the most important one that you need to implement. It should return an array or collection of about 5 to 8 search results, preferably with thumbnail images.</p>
<p>Implementing <strong>GetSuggestions</strong> is a little bit harder, and we don’t expect everyone to do it. The idea of this method is to return suggestions for other search <em>terms.</em> For example, if the supplied term was “Aus” you might return “Australia” and “Austria” as suggestions. The process of generating these results from your data is naturally a bit harder.</p>
<p><img style="display:inline;border-width:0;margin:0 0 0 50px;" title="Results" border="0" alt="Results" src="http://tatham.files.wordpress.com/2009/07/results.png?w=592&#038;h=230" width="592" height="230" /> </p>
<p>At this point you have a fully functional OpenSearch endpoint.</p>
<p>The last step is to tell the world about it by adding a small snippet of HTML to the <strong>&lt;head&gt;</strong> section of each of your pages:</p>
<pre class="brush: xml;">&lt;link title=&quot;My Site&quot; rel=&quot;search&quot; type=&quot;application/opensearchdescription+xml&quot; href=&quot;~/OpenSearch.ashx&quot; /&gt;</pre>
<p>Voila! Your users will now get to experience full OpenSearch support from your website:</p>
<p><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;margin:0 0 0 50px;" title="VisualSearch" border="0" alt="VisualSearch" src="http://tatham.files.wordpress.com/2009/07/visualsearch.png?w=401&#038;h=326" width="401" height="326" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tatham.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tatham.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tatham.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tatham.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tatham.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tatham.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tatham.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tatham.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tatham.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tatham.wordpress.com/364/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tatham.oddie.com.au&blog=171289&post=364&subd=tatham&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.tatham.oddie.com.au/2009/07/19/announcing-opensearch-on-asp-net-made-super-easy-with-the-opensearch-toolkit/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/459b8249e2b4dba8169774892cab0d48?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">tatham</media:title>
		</media:content>

		<media:content url="http://tatham.files.wordpress.com/2009/07/reference.png" medium="image">
			<media:title type="html">Reference</media:title>
		</media:content>

		<media:content url="http://tatham.files.wordpress.com/2009/07/generichandler2.png" medium="image">
			<media:title type="html">GenericHandler</media:title>
		</media:content>

		<media:content url="http://tatham.files.wordpress.com/2009/07/baseclass.png" medium="image">
			<media:title type="html">BaseClass</media:title>
		</media:content>

		<media:content url="http://tatham.files.wordpress.com/2009/07/description1.png" medium="image">
			<media:title type="html">Description</media:title>
		</media:content>

		<media:content url="http://tatham.files.wordpress.com/2009/07/results.png" medium="image">
			<media:title type="html">Results</media:title>
		</media:content>

		<media:content url="http://tatham.files.wordpress.com/2009/07/visualsearch.png" medium="image">
			<media:title type="html">VisualSearch</media:title>
		</media:content>
	</item>
		<item>
		<title>What&#8217;s wrong with Outlook?</title>
		<link>http://blog.tatham.oddie.com.au/2009/07/05/whats-wrong-with-outlook/</link>
		<comments>http://blog.tatham.oddie.com.au/2009/07/05/whats-wrong-with-outlook/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 03:52:30 +0000</pubDate>
		<dc:creator>Tatham Oddie</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tatham.wordpress.com/?p=340</guid>
		<description><![CDATA[It has been an interesting few weeks in the world of web standards for email.
The boys from Campaign Monitor executed a successful awareness campaign in the form of fixoutlook.org which rapidly racked up over 24,000 Tweets and overtook the Iran Election in Twitter’s trending topics. Unfortunately for all of us, it has been a case [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tatham.oddie.com.au&blog=171289&post=340&subd=tatham&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>It has been an interesting few weeks in the world of web standards for email.</p>
<p>The boys from <a href="http://www.campaignmonitor.com/">Campaign Monitor</a> executed a successful awareness campaign in the form of <a href="http://fixoutlook.org/">fixoutlook.org</a> which rapidly racked up over 24,000 Tweets and overtook the Iran Election in Twitter’s trending topics. Unfortunately for all of us, it has been a case of <a href="http://blogs.msdn.com/outlook/archive/2009/06/24/the-power-of-word-in-outlook.aspx">message received – but not understood</a>.</p>
<h2>The Core Problem</h2>
<p>Back in 2007, Microsoft swapped the Outlook rendering engine from Internet Explorer to Word. This in itself is not a problem at all; and actually delivered some really good improvements. There was now one-to-one fidelity between the authoring and viewing experiences because they were one and the same.</p>
<p>I <b><u>like</u></b> having Word as my authoring tool. I <b><u>like</u></b> features such as SmartArt and the context aware picture tools.</p>
<p>In making this switch though, we inherited the woeful CSS support that Word has. <a href="http://msdn.microsoft.com/en-us/library/aa338201.aspx">Microsoft’s developer documentation</a> lists Word 2007 as supporting “a <i>subset</i> of the standard HTML 4.01 specification, [...] the Internet Explorer 6.0 HTML specification [and] a <i>subset</i> of the standard Cascading Stylesheet Specification, Level 1.” That’s even <a href="http://msdn.microsoft.com/en-us/library/cc351024(VS.85).aspx">less support than Internet Explorer 5</a> had.</p>
<h2>Why does this matter?</h2>
<p>This isn’t just some web standards movement for the fun of it – there is real business impact here. No, it’s not something that end users will bang their head against. It’s something that affects all of us web designers.</p>
<p>Two of the key areas that are lacking in the rendering engine are support for the <b>float</b> and <b>background-image</b>. The former throws us back to the dark ages of table based layouts and all their inherent accessibility and layout issues. The latter means that there are some designs you just can’t do at all. Try placing today’s date on top of a graphic header in an email and let me know how you go.</p>
<p>In a comment that I consider a bit unfair, Microsoft’s official response referred to Campaign Monitor as makers of “email marketing campaign” software (complete with those quotes). Another thread I stumbled across described the fixoutlook.org campaign as being about the ability to deliver “bloated HTML with pixel trackers, domain redirectors and Google Ads”.</p>
<p>This is <u>not</u> a movement to aid in the delivering of spam. There are legitimate reasons for delivering automated and/or bulk emails to users. Campaign Monitor goes <a href="http://www.campaignmonitor.com/anti-spam/">above and beyond the legal requirements</a> to make sure their system is not misused.</p>
<p>This movement <u>is</u> about being better online citizens:</p>
<ul>
<li>Bloated HTML? Float-based layouts are much leaner and faster to render than table-based layouts. </li>
<li>Pixel trackers? We can do that in Word already – no change here. </li>
<li>Domain redirectors? I don’t even know what they are in this context and <a href="http://www.bing.com/search?q=domain+redirectors&amp;go=&amp;form=QBRE&amp;filt=all&amp;qs=n">Bing doesn’t seem to either</a>. </li>
<li>Google Ads? We’re not talking about running scripts at all. </li>
</ul>
<p><i><u></u></i></p>
<h2>Why does it really matter?</h2>
<p>Personally, I think <a href="http://twitter.com/jackmcintyre/status/2319431945">one of the most amusing demonstrations</a> of why this really matters comes from one of Microsoft’s own newsletters:</p>
<p align="center"><a title="XBox Newsletter" href="http://www.flickr.com/photos/tatham/3689917184/"><img style="border-width:0;" border="0" alt="XBox Newsletter" src="http://farm3.static.flickr.com/2558/3689917184_2b7bbaafaa_o.jpg" width="680" height="208" /></a></p>
<p>Notice that message on the top? “Read this issue online if you can’t see the images <u>or are using Outlook 2007.</u>” The authors of this newsletter probably deemed that Outlook 2007’s rendering engine required too much extra work for them to support it that the business case just didn’t exist.</p>
<p>We’re going through this same experience at the moment for one of the largest online presences in Australia. Having got our templates working in all of the major email clients except Outlook 2007 and Gmail, it was time to see what we could do about these last two stubborn children. In the end, it took twice the amount of time to make it Outlook 2007 compatible than it did to develop it in the first place. (And no, Gmail is never a pretty story either but that’s not an excuse Microsoft should be using.)</p>
<p>It’s not all about mass marketing either.</p>
<p>Here’s how one of my opt-in Twitter notifications renders side-by-side in Word and IE:</p>
<p align="center"><a href="http://www.flickr.com/photos/tatham/3689210360/sizes/o/"><img style="border-width:0;" border="0" src="http://farm4.static.flickr.com/3653/3689210360_e1e97eb862.jpg" /></a></p>
<p align="center">(click for full size)</p>
<h2>Why now?</h2>
<p>There have been some comments floating around asking why we’re only just starting to care now. I think this is a valid question, with two answers.</p>
<p>First and foremost, email has always been a right pain and thus the Email Standards Project was born in 2007. This project has gone on to make head way with some of the biggest names in the email game. Unfortunately though, there has been lack lustre response from Microsoft to date (including even to this targeted campaign).</p>
<p>Secondly, while this problem has been present since Outlook 2007, the big concern is that there doesn’t appear to have been any recourse made in Outlook 2010. To be fair, no official builds have been released yet and thus the fixoutlook.org campaign is being driven on evidence gained from a pre-beta build. With all that in mind though, you’d think that Microsoft could have mentioned something in their reply if they were working in this area. They didn’t. Also, now is our last chance to try and make an impact on Outlook 2010 before it gets locked down into the full testing regime.</p>
<h2>Standard? What standard?</h2>
<p><a href="http://blogs.msdn.com/outlook/archive/2009/06/24/the-power-of-word-in-outlook.aspx">Microsoft’s official response</a> correctly identifies that “there is no widely-recognized consensus in the industry about what subset of HTML is appropriate for use in e-mail for interoperability.” They are also correct in identifying that “the Email Standards Project does not represent a sanctioned standard or an industry consensus in this area.”</p>
<p>As I highlighted at the start of this post, <a href="http://msdn.microsoft.com/en-us/library/aa338201.aspx">Microsoft have explicitly stated</a> that the HTML and CSS support in Word 2007 is but a <i>subset</i> of existing standards. It is also interesting to note that they refer to the Internet Explorer 6.0 HTML Specification, another document which is not a sanctioned standard or an industry consensus in this area (or any, really).</p>
<p>It should be recognised that Email Standards Project is <u>not</u> about developing a new standard, or even a subset of an existing one. It does <u>not</u> portray itself to be a standards organisation at all.</p>
<p>This is demonstrated on their homepage by the clear mission statement:</p>
<blockquote><p>Our goal is to help designers understand why web standards are so important for email, while working with email client developers to ensure that emails render consistently. This is a community effort to improve the email experience for both designers and readers alike.</p>
</blockquote>
<p>In doing so, they have developed an acid test that they can use to measure the relative performance of each of the clients. This test is a subset of the existing standards, and a subset that they have arbitrarily agreed upon, however it is simply a tool for providing relative comparisons in the same way that we use the <a href="http://acid1.acidtests.org/">ACID1</a>, <a href="http://acid2.acidtests.org/">ACID2</a> and <a href="http://acid3.acidtests.org/">ACID3</a> tests for web browsers. In fact, the IE 8 team considered passing ACID2 to be <a href="http://blogs.msdn.com/ie/archive/2007/12/19/internet-explorer-8-and-acid2-a-milestone.aspx">a milestone for their product’s development</a>.</p>
<h2>Meet in the middle?</h2>
<p>The <a href="http://www.flickr.com/photos/freshview/3637814200/sizes/o/">rendering comparison provided on fixoutlook.org</a> does include one little morsel of hope. At the top of the Outlook 2010 rendering, you’ll notice an information bar that says “If there are problems with how this message is displayed, click here to view it in a web browser”. We can fairly safely assume that this will either flick the rendering engine to IE for that message only, or save it out to a temporary location and fire up the user’s default browser. The latter will have some challenges around embedded MIME data, however I imagine this is something they would have already solved in the pre-Word days of Outlook’s rendering.</p>
<p>Let’s get back to the original issue for a second: Word is being used to ensure a congruent authoring and rendering experiences, and a side effect of this is that emails authored with specific HTML and CSS do not render well.</p>
<p>Sound familiar? Web browsers solved this problem years ago with the introduction of multiple rendering modes driven by doctype switching. This has been adopted by every major browser manufacturer, including Microsoft, as a way of ensuring wide compatibility with varying levels of standards support.</p>
<p>The idea is by no means unique, but what’s stopping us from having Word as the rendering engine for emails received from another Outlook instance and IE as the rendering engine for emails the rest of the time?</p>
<ol>
<li>There is evidently code there already to detect when an IE-based render would produce better quality results. </li>
<li>MIME already includes enough information for one to determine what application authored a message. </li>
<li>I don’t think anybody is currently too concerned about the amount of rendering that is preserved when one attempts to forward an EDM. This is troublesome ground across every email client out there. </li>
</ol>
<p>We <u>don’t</u> need to radically change Word to support a whole bunch of new renderings. We <u>don’t</u> need to tear Word out of Outlook (despite what some of the campaign supporters have been saying).</p>
<p>All we’re asking for is a reliable and consistent way for the web developers of the world to deliver styled emails to Oulook, one of the best messaging platforms out there.</p>
<h2></h2>
<h2>Updates</h2>
<p><strong>6th July, 1501:</strong> John Liu <a href="http://blog.tatham.oddie.com.au/2009/07/05/whats-wrong-with-outlook/#comment-13939">accurately brought up the anti-trust restrictions</a> around the packaging of Internet Explorer. These restrictions apply to the shipping of Internet Explorer as a product, and do not relate to the underlying rendering engine (mshtml.dll). In fact, The Help &amp; Support interface in Windows 7 relies on this rendering engine itself:</p>
<p><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="image" border="0" alt="image" src="http://tatham.files.wordpress.com/2009/07/image.png?w=465&#038;h=385" width="465" height="385" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tatham.wordpress.com/340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tatham.wordpress.com/340/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tatham.wordpress.com/340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tatham.wordpress.com/340/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tatham.wordpress.com/340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tatham.wordpress.com/340/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tatham.wordpress.com/340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tatham.wordpress.com/340/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tatham.wordpress.com/340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tatham.wordpress.com/340/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tatham.oddie.com.au&blog=171289&post=340&subd=tatham&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.tatham.oddie.com.au/2009/07/05/whats-wrong-with-outlook/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/459b8249e2b4dba8169774892cab0d48?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">tatham</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2558/3689917184_2b7bbaafaa_o.jpg" medium="image">
			<media:title type="html">XBox Newsletter</media:title>
		</media:content>

		<media:content url="http://farm4.static.flickr.com/3653/3689210360_e1e97eb862.jpg" medium="image" />

		<media:content url="http://tatham.files.wordpress.com/2009/07/image.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Diagnosing Stack Overflow Faults in ASP.NET Production Environments</title>
		<link>http://blog.tatham.oddie.com.au/2009/07/04/diagnosing-stack-overflow-faults-in-asp-net-production-environments/</link>
		<comments>http://blog.tatham.oddie.com.au/2009/07/04/diagnosing-stack-overflow-faults-in-asp-net-production-environments/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 23:53:08 +0000</pubDate>
		<dc:creator>Tatham Oddie</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tatham.oddie.com.au/?p=327</guid>
		<description><![CDATA[WinDbg is a tool that is immensely useful, but painfully hard to get any value from if you don’t know how to use it. On a few occasions I’ve found myself in a situation where I knew that WinDbg could give me the answer, but I didn’t have enough knowledge of how to use it.
This [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tatham.oddie.com.au&blog=171289&post=327&subd=tatham&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>WinDbg is a tool that is immensely useful, but painfully hard to get any value from if you don’t know how to use it. On a few occasions I’ve found myself in a situation where I knew that WinDbg could give me the answer, but I didn’t have enough knowledge of how to use it.</p>
<p>This week we performed a production deployment on one of the projects I am involved in. Pretty soon after, we started to notice some issues cropping up that were affecting the performance and stability of the whole site.</p>
<p>In this scenario, WinDbg was a life saver for us. I can’t think of another way that we would have been able to identify and resolve this problem.</p>
<p>The first sign that something was wrong was this event getting fired across the whole front-end tier:</p>
<p><code>03 Jul 2009  08:32:43 AM<br />
Computer: WEBTIER14<br />
Monitor Title: "Event Log Monitor" (Type=Event Log Monitor)<br />
Description:<br />
* Event Time: 03 Jul 2009 08:32:42 AM<br />
* Source: .NET Runtime 2.0 Error Reporting<br />
* Event Log: Application<br />
* Type: Error Event<br />
* Event ID: 1000<br />
* Faulting application w3wp.exe, version 6.0.3790.3959, stamp 45d6968e, faulting module kernel32.dll, version 5.2.3790.4062, stamp 4626467c, debug? 0, fault address 0x00022366.</code></p>
<p>We also noted that CPU usage was spiking erratically and was well above the average we would expect for the number of firewall connections we had open.</p>
<p>This event log entry was telling us that the w3wp worker process was faulting in an unrecoverable way, causing the application pool to be torn down in IIS. The nature of the fault was also causing the Windows Error Reporting <code>dw20.exe</code> process to trigger and try capturing a mini dump. These rapid recycling combined with the CPU and IO intensive task of capturing a mini dump was killing our servers and we needed to act fast.</p>
<p>The first step was to work out what was causing the process to be torn down in the first place, as the impact of Windows Error Reporting’s automated analysis was only a secondary issue. To capture this information, I used the <code>adplus</code> script in the <a href="http://www.microsoft.com/whdc/devtools/debugging/default.mspx">Debugging Tools for Windows package</a> to capture a dump.</p>
<p>In its default configuration, adplus will capture a crash dump on any first chance exception. Being an ASP.NET application there are a number of exceptions that we expect to be thrown as 404s are reported, redirects are performed, etc. As such, running adplus in its default configuration was causing it to grab the crash dump too frequently and not giving us the fault that was causing the complete teardown.</p>
<p>To capture the process teardown fault, I ran adplus with these parameters:</p>
<p><code>adplus.vbs -pn w3wp.exe -c Unknown.cfg</code></p>
<p>The first parameter just says that we want to capture dump data for the <code>w3wp.exe</code> process. The second parameter is the interesting one – I am passing in a configuration file that includes some exception filters. I grabbed this config <a href="http://blogs.msdn.com/tess/archive/2008/05/06/asp-net-crash-stackoverflowexception-with-server-transfer.aspx">from Tess&#8217; blog</a>.</p>
<p>The content of the configuration file is fairly simple XML that describes the unknown fault scenario:</p>
<pre class="brush: xml;">
&lt;adplus&gt;
    &lt;settings&gt;
        &lt;runmode&gt; CRASH &lt;/runmode&gt;
    &lt;/settings&gt;
    &lt;exceptions&gt;
        &lt;config&gt;
            &lt;code&gt;AllExceptions&lt;/code&gt;
            &lt;actions1&gt;Log&lt;/actions1&gt;
            &lt;actions2&gt;MiniDump;Log;EventLog&lt;/actions2&gt;
        &lt;/config&gt;
        &lt;newexception&gt;
            &lt;code&gt; 0xe053534f &lt;/code&gt;
            &lt;name&gt; Unknown_Exception &lt;/name&gt;
        &lt;/newexception&gt;
        &lt;config&gt;
            &lt;code&gt; 0xe053534f &lt;/code&gt;
            &lt;actions1&gt;FullDump;Log;EventLog&lt;/actions1&gt;
            &lt;actions2&gt;FullDump;Log;EventLog&lt;/actions2&gt;
        &lt;/config&gt;
    &lt;/exceptions&gt;
&lt;/adplus&gt;
</pre>
<p>With the debugger now attached, it was a simple matter of waiting for the problem to occur. In our scenario it was happening every 10 to 15 minutes per server, so it took a while for me to capture the dump. Finally, the console showed “Dump file successfully written”.</p>
<p>To analyse the dump file, I opened <code>windbg.exe</code>, chose Open Crash Dump and selected the <code>.dmp</code> file that had been written out. You’ll usually find it in a CrashDump folder next to where you ran adplus from.</p>
<p>As we are working with a .NET application, but WinDbg is a native debugger, my next step was to load a set of debugger helpers called SOS. This is basically a plugin for WinDbg that lets us access information about the CLR state.</p>
<p>To load it, run:</p>
<p><code>.loadby sos mscorwks</code></p>
<p>The period at the start says it’s a WinDbg core command. The next parameter is the name of the library we want to load into the debugger. The final parameter is basically a relative file base – we’re telling WinDbg to load SOS from the same location that <code>mscorwks</code> had been loaded from. <code>mscorwks</code> is the .NET runtime, so this approach helps ensure we are loading the correct version and architecture of SOS and it saves us from having to write out the full path.</p>
<p>Next, I wanted to see what point of our application we were in when the process faulted. With SOS loaded, the command is quite simple:</p>
<p><code>!clrstack</code></p>
<p>Instantly, it was obvious that we had a stack overflow problem. This was made clear by literally hundreds of repeated frames on our call stack. It also explained why our ASP.NET Health Monitoring wasn&#8217;t reporting an exception, as a stack overflow causes the whole process to be torn down before any exception handling code can be run.</p>
<p>Here’s a short snippet (with the project details masked out):</p>
<p><code>...<br />
CompanyName.Project.Web.Logic.Component.Method1(System.String, System.Int32)<br />
CompanyName.Project.Web.Logic.Component.Method2(System.String)<br />
CompanyName.Project.Web.Logic.Component.Method1(System.String, System.Int32)<br />
CompanyName.Project.Web.Logic.Component.Method2(System.String)<br />
CompanyName.Project.Web.Logic.Component.Method1(System.String, System.Int32)<br />
CompanyName.Project.Web.Logic.Component.Method2(System.String)<br />
CompanyName.Project.Web.Logic.Component.Method1(System.String, System.Int32)<br />
CompanyName.Project.Web.Logic.Component.Method2(System.String)<br />
CompanyName.Project.Web.Logic.Component.Method1(System.String, System.Int32)<br />
CompanyName.Project.Web.Logic.Component.Method2(System.String)<br />
CompanyName.Project.Web.Logic.Component.Method1(System.String, System.Int32)<br />
CompanyName.Project.Web.Logic.Component.Method2(System.String)<br />
CompanyName.Project.Web.Logic.Component.Method1(System.String, System.Int32)<br />
CompanyName.Project.Web.Logic.Component.Method2(System.String)<br />
...</code></p>
<p>The component in question is used across almost all of our pages and the site wasn’t completely down, so I could now derive that it was being caused by a very specific piece of data. This leads us to our next challenge, which is to find out what which record was triggering the problem.</p>
<p>To do so, I ran:</p>
<p><code>!clrstack -p</code></p>
<p>The argument of <code>-p</code> asks SOS to list out all of the parameters for each stack frame.</p>
<p>Finding out the URL of the current request is a non-trivial task, and not all parameters are available due to runtime optimisations. Rather than persisting in a search for the URL, it was much easier to grab another stack frame which included the information I needed:</p>
<p><code>1947ed28 1abb1c7e  CompanyName.Project.Web.Logic.Presenters.RetailItemPresenter.View_ItemLoading(System.Object, CompanyName.Project.Web.Logic.Views.ItemLoadingEventArgs)<br />
    PARAMETERS:<br />
        this = 0x04144bf8<br />
        sender =<br />
        e = 0x04151b38</code></p>
<p>This is the event handler on one of our presenters being called as a result of the <code>ItemLoading</code> event being fired on the corresponding view. This approach is specific to <a href="http://webformsmvp.codeplex.com">our MVP architecture</a>, but it was a known and simple entry point into most of the stack. Try and look for an equivalent call in your own stack.</p>
<p>I could now see that it was a particular retail item triggering the problem, and I knew that the information I needed was in the event arguments. You can see the parameter on the stack frame shown as <code>e = 0x04151b38</code>. That number is the memory location of the object we need.</p>
<p>To get the object, I then ran:</p>
<p><code>!do  0x04151b38</code></p>
<p>The <code>!do</code> command is a shortcut for <code>!DumpObject</code>, and gave us this output:</p>
<p><code>Name: CompanyName.Project.Web.Logic.Views.ItemLoadingEventArgs<br />
MethodTable: 19ef2170<br />
EEClass: 19d49b70<br />
Size: 12(0xc) bytes<br />
 (c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\aef04219\e69835b3\assembly\dl3\29e5062003a4007_a4fac901\CompanyName.Project.Web.Logic.DLL)<br />
Fields:<br />
      MT    Field   Offset                 Type VT     Attr    Value Name<br />
7932a400  4000183       4c     System.EventArgs  0   shared   static Empty<br />
    &gt;&gt; Domain:Value  001cc630:NotInit  00204700:03043914 &lt;&lt;<br />
793308ec  4000819        4        System.String  0 instance 0412522c &lt;RetailItemId&gt;k__BackingField</code></p>
<p>We can now see the <code>RetailItemId</code> property and its corresponding backing field. The <code>value</code> column on that line is <code>0412522c</code>, which is another memory reference.</p>
<p>Once again, we dump the memory reference:</p>
<p><code>!do 0412522c</code></p>
<p>This returns us the corresponding <code>System.String</code> object:</p>
<p><code>Name: System.String<br />
MethodTable: 793308ec<br />
EEClass: 790ed64c<br />
Size: 28(0x1c) bytes<br />
 (C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)<br />
String: 6T046<br />
Fields:<br />
      MT    Field   Offset                 Type VT     Attr    Value Name<br />
79332b38  4000096        4         System.Int32  1 instance        6 m_arrayLength<br />
79332b38  4000097        8         System.Int32  1 instance        5 m_stringLength<br />
793315cc  4000098        c          System.Char  1 instance       36 m_firstChar<br />
793308ec  4000099       10        System.String  0   shared   static Empty<br />
    &gt;&gt; Domain:Value  001cc630:02fe01d0 00204700:02fe01d0 &lt;&lt;<br />
7933151c  400009a       14        System.Char[]  0   shared   static WhitespaceChars<br />
    &gt;&gt; Domain:Value  001cc630:02fe0728 00204700:06fe0e14 &lt;&lt;</code></p>
<p>Hidden away on the sixth line there is the raw string value, <code>6T046</code>, which was the product id.</p>
<p>At this point, we had:</p>
<ol>
<li>Captured a complete memory dump of the w3wp.exe process when the fault occurred</li>
<li>Identified a stack overflow to be the cause of the fault</li>
<li>Identified the area of our code that was involved in the stack overflow</li>
<li>Identified the particular piece of data that was exposing the bug</li>
</ol>
<p>We could now:</p>
<ol>
<li>Perform a quick fix to the data to circumvent the bug and get the website performant and stable again</li>
<li>Reproduce the bug locally using the same data that caused the issue</li>
<li>Have the lazy Friday we&#8217;d been hoping for</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tatham.wordpress.com/327/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tatham.wordpress.com/327/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tatham.wordpress.com/327/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tatham.wordpress.com/327/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tatham.wordpress.com/327/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tatham.wordpress.com/327/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tatham.wordpress.com/327/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tatham.wordpress.com/327/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tatham.wordpress.com/327/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tatham.wordpress.com/327/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tatham.oddie.com.au&blog=171289&post=327&subd=tatham&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.tatham.oddie.com.au/2009/07/04/diagnosing-stack-overflow-faults-in-asp-net-production-environments/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/459b8249e2b4dba8169774892cab0d48?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">tatham</media:title>
		</media:content>
	</item>
		<item>
		<title>Video: Building great standards based websites for the big wide world with ASP.NET 4.0</title>
		<link>http://blog.tatham.oddie.com.au/2009/06/18/video-building-great-standards-based-websites-for-the-big-wide-world-with-asp-net-4-0/</link>
		<comments>http://blog.tatham.oddie.com.au/2009/06/18/video-building-great-standards-based-websites-for-the-big-wide-world-with-asp-net-4-0/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 23:54:27 +0000</pubDate>
		<dc:creator>Tatham Oddie</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tatham.wordpress.com/2009/06/18/video-building-great-standards-based-websites-for-the-big-wide-world-with-asp-net-4-0/</guid>
		<description><![CDATA[The video recording from Damian and my session at REMIX Sydney last week is now online. Thanks to some funky aspect ratio issues we both look really buff too.
In this session, two ASP.NET MVPs will share their experiences from building Australia’s largest e-commerce site with ASP.NET Web Forms. They’ll show you how to be a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tatham.oddie.com.au&blog=171289&post=318&subd=tatham&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>The video recording from <a href="http://damianedwards.wordpress.com/">Damian</a> and my session at <a href="http://www.microsoft.com/australia/remix/">REMIX Sydney</a> last week is now online. Thanks to some funky aspect ratio issues we both look really buff too.</p>
<blockquote><p><em>In this session, two ASP.NET MVPs will share their experiences from building Australia’s largest e-commerce site with ASP.NET Web Forms. They’ll show you how to be a good web citizen by covering standards compliance (properly!), cross browser and accessibility considerations, non-JavaScript support, as well as coding techniques like the Model-View-Presenter pattern to improve maintainability and testing. Along the way, there’ll be plenty of discussion of the differences between Web Forms and ASP.NET MVC in each area, as well as an early peek at some of the new features coming in ASP.NET 4.0 and VS 2010.</em></p>
<p><a href="http://www.microsoft.com/australia/remix/videos/?vid=v20">Building great standards based websites for the big wide world with ASP.NET 4.0 – watch online</a></p>
<p><a href="http://mediadl.microsoft.com/mediadl/www/a/australia/Remix09/Asp.net.wmv">Building great standards based websites for the big wide world with ASP.NET 4.0 – download WMV</a></p>
</blockquote>
<p>The resources from our talk are now all online (including the ones that hadn’t been released yet on the day):</p>
<ul>
<li><a href="http://webformsmvp.codeplex.com/">Damian’s ASP.NET Web Forms Model-View-Presenter (MVP) Framework</a> (Open source under MS-PL)</li>
<li><a href="http://vsxhtml11templates.codeplex.com/">Damian’s Visual Studio XHTML 1.1 Templates</a> (Open source under MIT)</li>
<li><a href="http://blog.tatham.oddie.com.au/2009/06/15/released-xhtml-markup-sanitizer/">My XHTML Markup Sanitizer</a> (Open source under MS-PL)</li>
</ul>
<p>We also talked about the <a href="http://cssfriendly.codeplex.com/">CSS Friendly Control Adapters</a> which are again open source, under MS-PL. </p>
<p>While you’re checking out the videos, take a look at <a href="http://www.microsoft.com/australia/remix/videos/?vid=v01">Jordan’s rockin’ Silverlight 3 Super Session</a>. Not all of the videos are up yet (like, most of them aren’t), and I imagine that from the feedback flowing in there might be an updated version of the videos soon, so <a href="http://www.microsoft.com/australia/remix/videos/default.aspx">keep watching the videos page</a> for some other really good content.</p>
<p><strong>Updated @ 1601, 18th June:</strong> The video page interface has been updated to support deep linking so I’ve update this post to include links to the in-page players.</p>
<p><strong>Updated @ 1053, 20th June:</strong> Added links to resources now that they’re all been published.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tatham.wordpress.com/318/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tatham.wordpress.com/318/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tatham.wordpress.com/318/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tatham.wordpress.com/318/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tatham.wordpress.com/318/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tatham.wordpress.com/318/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tatham.wordpress.com/318/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tatham.wordpress.com/318/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tatham.wordpress.com/318/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tatham.wordpress.com/318/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tatham.oddie.com.au&blog=171289&post=318&subd=tatham&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.tatham.oddie.com.au/2009/06/18/video-building-great-standards-based-websites-for-the-big-wide-world-with-asp-net-4-0/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
<enclosure url="http://mediadl.microsoft.com/mediadl/www/a/australia/Remix09/Asp.net.wmv" length="327609499" type="video/x-ms-wmv" />
	
		<media:content url="http://0.gravatar.com/avatar/459b8249e2b4dba8169774892cab0d48?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">tatham</media:title>
		</media:content>
	</item>
	</channel>
</rss>