<?xml version="1.0" encoding="UTF-8"?>
<rss 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:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Aaron Lerch</title>
	<atom:link href="http://www.aaronlerch.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.aaronlerch.com/blog</link>
	<description />
	<lastBuildDate>Fri, 25 Sep 2009 18:08:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<geo:lat>39.866913</geo:lat><geo:long>-86.123236</geo:long><creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Two Components for your Toolbox</title>
		<link>http://feedproxy.google.com/~r/aaronlerch/~3/6CN3pRZFoPg/</link>
		<comments>http://www.aaronlerch.com/blog/2009/09/25/two-components-for-your-toolbox/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 06:36:11 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.aaronlerch.com/blog/2009/09/25/two-components-for-your-toolbox/</guid>
		<description><![CDATA[Any desktop application I write from now on will contain these two interfaces. They’re useful enough I thought I should share. Also note, with upcoming improvements in .NET 4.0 (or higher) they might be rendered moot. So far, I don’t think they are, as it’s still difficult to test the code itself that performs asynchronous [...]]]></description>
			<content:encoded><![CDATA[<p>Any desktop application I write from now on will contain these two interfaces. They’re useful enough I thought I should share. Also note, with upcoming improvements in .NET 4.0 (or higher) they might be rendered moot. So far, I don’t think they are, as it’s still difficult to test the code itself that performs asynchronous operations.</p>
<p>First, is an abstraction around the User Interface thread, IUserInterfaceContext. This exists today in the form of <a href="http://msdn.microsoft.com/en-us/library/system.threading.synchronizationcontext.aspx">SynchronizationContext</a>, but I favor this specific interface because</p>
<ol>
<li>It’s more explicit (the SynchronizationContext applies to more than just the main UI thread) whereas this is very clear what its purpose is.</li>
<li>The API is cleaner – passing a “state” is unnecessary with nested closures.</li>
<li>It’s easier to grab out of an IoC container. Because a SynchronizationContext is only specific to the context it was created in (which could be a background thread) it’s not meaningful to put a SynchronizationContext argument in your constructor. Which one do you want?</li>
</ol>
<pre class="brush: csharp;">public interface IUserInterfaceContext
{
    void Execute(Action action);
    void ExecuteAndBlock(Action action);
}</pre>
<p>Now, any component in my application can execute code on the UI thread extremely easily. I just register the implementation of IUserInterfaceContext (which does use a SynchronizationContext) when my application is started, which is on the UI thread.</p>
<p>The implementation could look something like this:</p>
<pre class="brush: csharp;">public class UserInterfaceContext : IUserInterfaceContext
{
    private readonly SynchronizationContext _syncContext;

    public UserInterfaceContext(SynchronizationContext syncContext)
    {</pre>
<pre class="brush: csharp;">        /* Ensure the SynchronizationContext passed in is the main UI thread context */
        _syncContext = syncContext;
    }

    public void ExecuteAndBlock(Action action)
    {
        if (_syncContext != null)
        {
            _syncContext.Send(s =&gt; action(), null);
        }
        else
        {
            action();
        }
    }

    /// &lt;inheritdoc /&gt;
    public void Execute(Action action)
    {
        if (_syncContext != null)
        {
            _syncContext.Post(s =&gt; action(), null);
        }
        else
        {
            ThreadPool.QueueUserWorkItem(s =&gt; action(), null);
        }
    }
}</pre>
<p>Secondly, is a more generalized example of Jeremy Miller’s <a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/02/15/build-your-own-cab-18-the-command-executor.aspx">ICommandExecutor</a>, which is even more generalized as the <a href="http://blog.gurock.com/postings/active-objects-and-futures-a-concurrency-abstraction-implemented-for-c-and-net/290/">Active Object pattern</a>. I named mine “IAsyncExecutor” because it executes any code asynchronously. The advantage with this approach is that it drastically simplifies test activities to be able abstract multithreading (to a point) and allow a test to run single threaded. That is nothing but pure win. We’ve also found that using the interface makes the code read better than using a bunch of BeginInvoke/EndInvoke’s or the ThreadPool, or an async pattern such as &#8220;void FooAsync(AsyncCallback callback, object state);</p>
<pre class="brush: csharp;">public interface IAsyncExecutor
{
    void Execute(Action action);
    void Execute(Action action, Action after, bool callbacksOnUIThread);
    void Execute(Action action, Action after, Action&lt;Exception&gt; error, bool callbacksOnUIThread);
}</pre>
<p>You’ll notice that IAsyncExecutor looks a lot like IUserInterfaceContext, and in fact, it can use it under the covers if the callbacksOnUIThread is true.</p>
<p>Both of these are simple interfaces, with trivial implementations, but you’d be surprised how often I’ve wished I’ve had them in the past. What are some “core” interfaces/services/etc that you <strong>*must have*</strong> in your toolbox?</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/aaronlerch?a=6CN3pRZFoPg:PXW4s84Kla0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/aaronlerch?i=6CN3pRZFoPg:PXW4s84Kla0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/aaronlerch?a=6CN3pRZFoPg:PXW4s84Kla0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/aaronlerch?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/aaronlerch?a=6CN3pRZFoPg:PXW4s84Kla0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/aaronlerch?i=6CN3pRZFoPg:PXW4s84Kla0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/aaronlerch?a=6CN3pRZFoPg:PXW4s84Kla0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/aaronlerch?i=6CN3pRZFoPg:PXW4s84Kla0:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/aaronlerch/~4/6CN3pRZFoPg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.aaronlerch.com/blog/2009/09/25/two-components-for-your-toolbox/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.aaronlerch.com/blog/2009/09/25/two-components-for-your-toolbox/</feedburner:origLink></item>
		<item>
		<title>The Importance of Context</title>
		<link>http://feedproxy.google.com/~r/aaronlerch/~3/82BrLMDASC8/</link>
		<comments>http://www.aaronlerch.com/blog/2009/08/22/the-importance-of-context/#comments</comments>
		<pubDate>Sun, 23 Aug 2009 01:58:08 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[misc]]></category>

		<guid isPermaLink="false">http://www.aaronlerch.com/blog/2009/08/22/the-importance-of-context/</guid>
		<description><![CDATA[The importance of context was brought jarringly to my attention the other day. This week was my intern’s last week, and as such he needed to fill out a “self evaluation” for HR. The first part of the eval was a simple 5-column table: various categories for evaluation, 3 boxes for “Did Not Meet”, “Met”, [...]]]></description>
			<content:encoded><![CDATA[<p>The importance of context was brought jarringly to my attention the other day. This week was my intern’s last week, and as such he needed to fill out a “self evaluation” for HR. The first part of the eval was a simple 5-column table: various categories for evaluation, 3 boxes for “Did Not Meet”, “Met”, or “Exceeded” expectations, and finally a box for comments. I personally think that’s a pretty hideous way to do a self evaluation, but I’ll ignore that for now. (I’d give myself a “Did Not Meet” for this post!)</p>
<p>My intern, being a pretty humble guy, put an “X” in each “Met” column and left no comments for himself, unsure of what to put. It looked something like this:</p>
<p><img src="http://s3.amazonaws.com:80/aaronlerch.com/images/self-eval-original.png" alt="" /></p>
<p>So I decided to “help him out” and provide some feedback since I think he did a very good job this summer. I made my edits and sent it back to him with a note saying we’d review it together the next day.</p>
<p><img src="http://s3.amazonaws.com:80/aaronlerch.com/images/self-eval-edited.png" alt="" /></p>
<p>At our daily standup the next morning he looked pretty depressed and dejected, which I noted, but didn’t think too much about. He sheepishly slipped into my office later that morning for our meeting, and only after we started talking did we realize that something was amiss. You see, I’m a native English-speaker who has spent my entire life in North America. As such, I have learned to read and process information from left to right. When I think about data, I put the lower value on the left and the higher on the right: lower &lt; higher.</p>
<p>Unfortunately, while filling out the review I had skimmed the table and just started editing. So what my intern received from me looked like this:</p>
<p><img src="http://s3.amazonaws.com:80/aaronlerch.com/images/self-eval-full.png" alt="" /></p>
<p>After my intern started breathing again, we had a good laugh about it. Well, I apologized and laughed and he laughed with relief in the “just got a last-minute pardon” kind of way. <img src='http://www.aaronlerch.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
There are two lessons here:</p>
<ol>
<li>Don’t make assumptions. (I should’ve read the document more thoroughly.)</li>
<li>Understand your user’s context. Present information in a way that flows with how they naturally think.</li>
</ol>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/aaronlerch?a=82BrLMDASC8:34qnV56IWQk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/aaronlerch?i=82BrLMDASC8:34qnV56IWQk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/aaronlerch?a=82BrLMDASC8:34qnV56IWQk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/aaronlerch?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/aaronlerch?a=82BrLMDASC8:34qnV56IWQk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/aaronlerch?i=82BrLMDASC8:34qnV56IWQk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/aaronlerch?a=82BrLMDASC8:34qnV56IWQk:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/aaronlerch?i=82BrLMDASC8:34qnV56IWQk:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/aaronlerch/~4/82BrLMDASC8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.aaronlerch.com/blog/2009/08/22/the-importance-of-context/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.aaronlerch.com/blog/2009/08/22/the-importance-of-context/</feedburner:origLink></item>
		<item>
		<title>Say Hello to My Little Internet</title>
		<link>http://feedproxy.google.com/~r/aaronlerch/~3/geXEMJwmI5U/</link>
		<comments>http://www.aaronlerch.com/blog/2009/08/20/say-hello-to-my-little-internet/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 07:20:42 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[services]]></category>

		<guid isPermaLink="false">http://www.aaronlerch.com/blog/2009/08/20/say-hello-to-my-little-internet/</guid>
		<description><![CDATA[Recently I’ve been thinking about options for exposing an application automation API for inter process integration scenarios. For example, a desktop application that exposes the ability for other applications to programmatically query information from it and/or invoke commands. I also had a few requirements. Whatever I choose should:

Let me inject core application services (or higher [...]]]></description>
			<content:encoded><![CDATA[<p><img style="display: inline; margin-left: 0px; margin-right: 0px" align="right" src="http://s3.amazonaws.com:80/aaronlerch.com/Scarface.png" />Recently I’ve been thinking about options for exposing an application automation API for inter process integration scenarios. For example, a desktop application that exposes the ability for other applications to programmatically query information from it and/or invoke commands. I also had a few requirements. Whatever I choose should:</p>
<ul>
<li>Let me inject core application services (or higher level aggregated services, or ANYTHING I WANT) by pulling them out of my IoC container </li>
<li>Not require the service to run in a new AppDomain </li>
<li>Be easy to use, configure, and integrate into my application </li>
<li>Be testable </li>
</ul>
<p>I’m going down the path of exposing a Web API (I would call it a RESTful service, but really it’s not). Of course my first stop was to investigate hosting ASP.NET MVC in a desktop application (which really just means hosing ASP.NET). There are a few <a href="http://www.west-wind.com/presentations/aspnetruntime/aspnetruntime.asp">articles</a> <a href="http://www.codeproject.com/KB/dotnet/usingaspruntime.aspx">out</a> there about how to do this, and for the “intended” scenario, it’s pretty easy.</p>
<p>Unfortunately the “intended” scenario is web hosting, which loads everything into a new AppDomain. And aside from some of the outer classes and factories, everything is marked private or internal so I can’t get at it without doing a bunch of reflection. Bah.</p>
<p>I’ve ended up taking a long look at <a href="http://www.openrasta.com/">OpenRasta</a>. OpenRasta was written with DI/IoC in mind, and it actually uses an internal IoC container for configuring the framework. More on that in a future post. It also has it’s own hosting support and API that have out-of-the-box implementations for ASP.NET, <a href="http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx">HttpListener</a>, and “In Memory”. But you could always implement your own hosting code and integrate it.</p>
<p>The key word in that entire paragraph was “HttpListener”. That’s built-in .NET support for for web request processing that is baked into Windows via the kernel-mode http.sys driver. It’s relatively easy to use, and it’s wonderful. OpenRasta integrates with my existing application infrastructure, and marries it up with support for a REST-style web API, enabling me to very quickly expose a web API that allows third parties to integrate with my application. This is going to be more and more important as things like Windows Gadgets are implemented which are restricted in terms of the kinds of ways they can communicate (web requests) and with whom they can communicate (localhost, etc.)</p>
<p>Unfortunately OpenRasta doesn’t support <a href="http://ninject.org/">Ninject</a>, which I use, so I’m implementing the support for it and will submit the patch soon.</p>
<p>So far I’m extremely happy with the solution as I think developer productivity will be through the roof (compared to other more invasive solutions like WCF) and client-side integrations won’t be that difficult (POX). For my scenario, it’s all right up my alley. The internetz work for ME now!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/aaronlerch?a=geXEMJwmI5U:Kz3RBKSW5q4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/aaronlerch?i=geXEMJwmI5U:Kz3RBKSW5q4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/aaronlerch?a=geXEMJwmI5U:Kz3RBKSW5q4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/aaronlerch?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/aaronlerch?a=geXEMJwmI5U:Kz3RBKSW5q4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/aaronlerch?i=geXEMJwmI5U:Kz3RBKSW5q4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/aaronlerch?a=geXEMJwmI5U:Kz3RBKSW5q4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/aaronlerch?i=geXEMJwmI5U:Kz3RBKSW5q4:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/aaronlerch/~4/geXEMJwmI5U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.aaronlerch.com/blog/2009/08/20/say-hello-to-my-little-internet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.aaronlerch.com/blog/2009/08/20/say-hello-to-my-little-internet/</feedburner:origLink></item>
		<item>
		<title>#3!</title>
		<link>http://feedproxy.google.com/~r/aaronlerch/~3/3Rxda__-84A/</link>
		<comments>http://www.aaronlerch.com/blog/2009/04/02/3/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 00:58:58 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.aaronlerch.com/blog/2009/04/02/3/</guid>
		<description><![CDATA[No, that’s not a bash command or a regular expression.  

#3 will be joining #2 and #1, and we are pumped.    Well, I’m pumped, my wife is just trying not to feel too sick. She’ll be pumped later, like in 5 years.  
]]></description>
			<content:encoded><![CDATA[<p>No, that’s not a bash command or a regular expression. <img src='http://www.aaronlerch.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><img src="http://s3.amazonaws.com:80/aaronlerch.com/images/ultrasound-3.jpg" /></p>
<p>#3 will be joining <a href="http://picasaweb.google.com/aaronlerch/FromHalloweenToThanksgiving#5275445275518695186">#2 and #1</a>, and we are pumped.    <br />Well, I’m pumped, my wife is just trying not to feel too sick. She’ll be pumped later, like in 5 years. <img src='http://www.aaronlerch.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/aaronlerch?a=3Rxda__-84A:SkQzsGtWTpI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/aaronlerch?i=3Rxda__-84A:SkQzsGtWTpI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/aaronlerch?a=3Rxda__-84A:SkQzsGtWTpI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/aaronlerch?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/aaronlerch?a=3Rxda__-84A:SkQzsGtWTpI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/aaronlerch?i=3Rxda__-84A:SkQzsGtWTpI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/aaronlerch?a=3Rxda__-84A:SkQzsGtWTpI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/aaronlerch?i=3Rxda__-84A:SkQzsGtWTpI:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/aaronlerch/~4/3Rxda__-84A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.aaronlerch.com/blog/2009/04/02/3/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://www.aaronlerch.com/blog/2009/04/02/3/</feedburner:origLink></item>
		<item>
		<title>Design Pattern Resources</title>
		<link>http://feedproxy.google.com/~r/aaronlerch/~3/7yKmcsAIcuo/</link>
		<comments>http://www.aaronlerch.com/blog/2009/04/02/design-pattern-resources/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 00:51:10 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.aaronlerch.com/blog/2009/04/02/design-pattern-resources/</guid>
		<description><![CDATA[I’ve had a few people ask me for a recommendation of some resources to learn design patterns. There’s a lot of good stuff “out there”, of course, but my response usually says just three things:
Read pretty much anything this guy writes,    Learn SOLID, and lern it güd. I recommend starting here.  [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve had a few people ask me for a recommendation of some resources to learn design patterns. There’s a lot of good stuff “out there”, of course, but my response usually says just three things:</p>
<p><a href="http://codebetter.com/blogs/jeremy.miller/"><strong>Read pretty much anything this guy writes</strong></a>,    <br /><strong>Learn </strong><a href="http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod"><strong>SOLID</strong></a><strong>, and lern it güd. </strong><a href="http://www.lostechies.com/blogs/chad_myers/archive/2008/03/07/pablo-s-topic-of-the-month-march-solid-principles.aspx"><strong>I recommend starting here.</strong></a>    <br /><em>and</em>    <br /><strong>Let me know if you have any questions and let’s chat.</strong></p>
<p>If you’re anything like me, you’ll find yourself up until 4 AM reading, reading, and reading as you link from post to post and article to article. I swear one of these days I will find <a href="http://www.shibumi.org/eoti.htm">the end of the internet</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/aaronlerch?a=7yKmcsAIcuo:UXIyKNoBpLQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/aaronlerch?i=7yKmcsAIcuo:UXIyKNoBpLQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/aaronlerch?a=7yKmcsAIcuo:UXIyKNoBpLQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/aaronlerch?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/aaronlerch?a=7yKmcsAIcuo:UXIyKNoBpLQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/aaronlerch?i=7yKmcsAIcuo:UXIyKNoBpLQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/aaronlerch?a=7yKmcsAIcuo:UXIyKNoBpLQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/aaronlerch?i=7yKmcsAIcuo:UXIyKNoBpLQ:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/aaronlerch/~4/7yKmcsAIcuo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.aaronlerch.com/blog/2009/04/02/design-pattern-resources/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.aaronlerch.com/blog/2009/04/02/design-pattern-resources/</feedburner:origLink></item>
		<item>
		<title>Debugging UI</title>
		<link>http://feedproxy.google.com/~r/aaronlerch/~3/_k_77YFOC1Y/</link>
		<comments>http://www.aaronlerch.com/blog/2008/12/15/debugging-ui/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 19:01:09 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[windows forms]]></category>

		<guid isPermaLink="false">http://www.aaronlerch.com/blog/2008/12/15/debugging-ui/</guid>
		<description><![CDATA[I&#8217;ve talked before about System.Threading.SynchronizationContext, as well as BeginInvoke/InvokedRequired/IsHandleCreated. In a multi-threaded Windows Forms application they can easily be mis-used, introducing difficult to find bugs.
One such not-so-subtle bug (application hang) is particularly nasty, and is described fairly well here. Distilled down, the application hangs, usually when the computer comes out of sleep mode, unlocks, or [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve talked before about <a href="http://www.aaronlerch.com/blog/2007/05/19/net-20-winforms-multithreading-and-a-few-long-days/">System.Threading.SynchronizationContext</a>, as well as <a href="http://www.aaronlerch.com/blog/2006/12/15/controltrifecta-invokerequired-ishandlecreated-and-isdisposed/">BeginInvoke/InvokedRequired/IsHandleCreated</a>. In a multi-threaded Windows Forms application they can easily be mis-used, introducing difficult to find bugs.</p>
<p>One such not-so-subtle bug (application hang) is particularly nasty, and is <a href="http://ikriv.com:8765/en/prog/info/dotnet/MysteriousHang.html">described fairly well here</a>. Distilled down, the application hangs, usually when the computer comes out of sleep mode, unlocks, or another similar event occurs. The hang happens in the firing of an event handler, called from &#8220;SystemEvents.OnUserPreferenceChanged&#8221;. The cause is that OnUserPreferenceChanged is trying to be super nice, and invoke the event in the appropriate context for each event subscriber. That means that if a Control subscribes to the event, the handler will be called on the UI thread. If user code (on a background thread) subscribes, the handler will be called on an arbitrary thread, etc. The problem occurs when, at some point in the past, a Form or Control was created on a background thread. The creation of the control &#8220;installed&#8221; a WindowsFormsSynchronizationContext as the current SynchronizationContext (this is default behavior). When OnUserPreferenceChanged attempts to Send (Invoke) to the appropriate thread context, it hangs because the WindowsFormsSynchronizationContext is on the wrong thread, and thus has no message pump with which to process messages.</p>
<p>Blah blah blah. Right now you&#8217;re thinking &#8220;Whatever dude, I&#8217;m a web developer, man, I&#8217;m just trying to fix this bug in that <strong>other</strong> jerk&#8217;s code.&#8221; Fair enough, you can read the linked post for more gory details. What you care about is the hard part. Well, hard for <em>web developers</em> anyway. <img src='http://www.aaronlerch.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  By the time the app hangs, it&#8217;s too late to find out where the problem occurred. In a medium-to-large application, how do you find the control that was created on the wrong thread? Here&#8217;s how to do it in a matter of seconds.</p>
<p><strong>1. Name your UI thread.</strong> If you&#8217;re not already doing this, it&#8217;s a good idea in general. I like to call mine &#8220;UI&#8221;, personally. In your &#8220;static void Main()&#8221; add this single line of code:</p>
<pre class="c#" name="code">Thread.CurrentThread.Name = "UI";</pre>
<p><strong>2. Set a breakpoint deep in the bowels of the BCL.</strong> What we want to do is cause our application to break when a WindowsFormsSynchronizationContext gets assigned to the current thread. I cracked open Reflector to look at the constructor for WindowsFormsSynchronizationContext:</p>
<p><img src="http://s3.amazonaws.com:80/aaronlerch.com/images/winforms_synccontext_ctor.png"></p>
<p>And I see that there&#8217;s a call to &#8220;Application.ThreadContext.FromCurrent()&#8221;. Close enough for government work, it&#8217;ll do for what I want. I didn&#8217;t feel like figuring out how to specify a constructor call when setting a breakpoint. (If you know how, leave a comment so we can all learn!) Add a breakpoint to that method call. In Visual Studio, go to the &#8220;Debug&#8221; &gt; &#8220;New Breakpoint&#8221; &gt; &#8220;Break at Function&#8230;&#8221; menu. In the &#8220;Function&#8221; area type the full path to the function: System.Windows.Forms.Application.ThreadContext.FromCurrent()</p>
<p><img src="http://s3.amazonaws.com:80/aaronlerch.com/images/new_breakpoint_threadcontext.png"></p>
<p>When you hit &#8220;OK&#8221; you&#8217;ll get a warning about IntelliSense not finding the specified location. Hit &#8220;Yes&#8221; to set the breakpoint anyway.</p>
<p><strong>3. Run your application.</strong> Depending on what version of Visual Studio you&#8217;re running, and whether you&#8217;ve got source-level debugging for the Framework turned on, you&#8217;ll either get the breakpoint on some code, or you&#8217;ll get this message box:</p>
<p><img src="http://s3.amazonaws.com:80/aaronlerch.com/images/no_source_code_msgbox.png"></p>
<p>It doesn&#8217;t matter, you can press &#8220;OK&#8221; or &#8220;Show Disassembly&#8221;, whatever floats your boat. Go to the &#8220;Call Stack&#8221; debugging window, right-click on the red breakpoint circle located at the top of the stack frame, and select &#8220;Breakpoint&#8221; &gt; &#8220;Filter&#8230;&#8221;</p>
<p><img src="http://s3.amazonaws.com:80/aaronlerch.com/images/breakpoint_filter.png"></p>
<p><strong>4. Add a filter to this breakpoint so that it only breaks when the current threads&#8217; name isn&#8217;t &#8220;UI&#8221;.</strong></p>
<p><img src="http://s3.amazonaws.com:80/aaronlerch.com/images/breakpoint_filter_non_ui_thread.png"></p>
<p>After you hit &#8220;OK&#8221;, continue running your application in the debugger. The first time a WindowsFormsSynchronizationContext is created and it&#8217;s not on the UI thread, BAM. There&#8217;s your problem, and there&#8217;s your stack trace allowing you to find the bad code.</p>
<p>This worked like a champ for me today, hopefully you have as much success with it too.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/aaronlerch?a=nlVZUEkD"><img src="http://feeds.feedburner.com/~f/aaronlerch?i=nlVZUEkD" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/aaronlerch?a=R1GvNCfT"><img src="http://feeds.feedburner.com/~f/aaronlerch?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/aaronlerch?a=WsPR7hMV"><img src="http://feeds.feedburner.com/~f/aaronlerch?i=WsPR7hMV" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/aaronlerch?a=N6Ak9kd8"><img src="http://feeds.feedburner.com/~f/aaronlerch?i=N6Ak9kd8" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/aaronlerch/~4/_k_77YFOC1Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.aaronlerch.com/blog/2008/12/15/debugging-ui/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.aaronlerch.com/blog/2008/12/15/debugging-ui/</feedburner:origLink></item>
		<item>
		<title>Case insensitive string comparisons with LINQ Dynamic Query</title>
		<link>http://feedproxy.google.com/~r/aaronlerch/~3/GuPfw2sI3PA/</link>
		<comments>http://www.aaronlerch.com/blog/2008/12/15/case-insensitive-string-comparisons-with-linq-dynamic-query/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 07:46:37 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[tips and tricks]]></category>

		<guid isPermaLink="false">http://www.aaronlerch.com/blog/2008/12/15/case-insensitive-string-comparisons-with-linq-dynamic-query/</guid>
		<description><![CDATA[LINQ rocks. It really does.
One down-side to LINQ is that, out of the box, it&#8217;s geared towards knowing your query structure at compile-time. The values can be dynamic, of course, but it&#8217;s assumed that the structure of your query is static. For example, if you want to select a set of &#34;Person&#34; objects from the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://msdn.microsoft.com/en-us/vbasic/aa904594.aspx">LINQ</a> rocks. It really does.</p>
<p>One down-side to LINQ is that, out of the box, it&#8217;s geared towards knowing your query structure at compile-time. The values can be dynamic, of course, but it&#8217;s assumed that the structure of your query is static. For example, if you want to select a set of &quot;Person&quot; objects from the &quot;People&quot; collection where Person.FirstName starts with &quot;Aar&quot;, you could write it as such:</p>
<pre class="c#" name="code">var results = from person in People
              where person.FirstName.StartsWith(&quot;Aar&quot;)
              select person;</pre>
<p>That&#8217;s all fine and good, but what about scenarios where you want to dynamically build up your query structure? In <a href="http://www.inin.com/">our</a> client application we have address books (directories) that include the ability to filter them on any, or nearly any, column:</p>
<p><img src="http://s3.amazonaws.com:80/aaronlerch.com/images/client_directory_filter.png" /></p>
<p>How would I accomplish this with LINQ? Not easily. Just ask <a href="http://www.google.com/search?q=expression+tree+site:ayende.com">Ayende</a> or <a href="http://www.google.com/search?q=expression+tree+site:blog.wekeroad.com">Rob Conery</a>, both of whom have blogged about some of their adventures in advanced usage scenarios. Enter the LINQ Dynamic Query sample from Microsoft. As usual, <a href="http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx">ScottGu&#8217;s got a good write-up</a>. In a nutshell, it&#8217;s a custom expression tree generator based on a limited (but useful) string-based query grammar. With Dynamic Query I could write the query above like this:</p>
<pre class="c#" name="code">var results = from person in People
              select person;
results = results.Where(&quot;FirstName.StartsWith(\&quot;Aar\&quot;)&quot;);</pre>
<p>It solved my problem nicely. Almost. As with my example above about matching FirstName&#8217;s, let me ask: how often does a user enter an exact case-sensitive match for what they&#8217;re looking for? I can save you the trouble and tell you: it doesn&#8217;t matter. It&#8217;s an unacceptable requirement for a user to have to match something exactly. It&#8217;s already questionable that we don&#8217;t automatically use fuzzy matching algorithms.</p>
<p>So what I really want is to specify a StringComparison enum value on the call to &quot;StartsWith&quot;:</p>
<pre class="c#" name="code">var results = from person in People
              select person;
results = results.Where(&quot;FirstName.StartsWith(\&quot;Aar\&quot;, System.StringComparison.OrdinalIgnoreCase)&quot;);</pre>
<p>Alas, this breaks. LINQ Dynamic Query doesn&#8217;t support enum values as parameters to methods. <em>So I added it.</em> I won&#8217;t redistribute the sample (I&#8217;m pretty sure I can&#8217;t, but I don&#8217;t care to anyway) so here&#8217;s what you need to do to add support for enum parsing. Note that I&#8217;ve only tested it with calls to string&#8217;s StartsWith(string, StringComparison) method. I don&#8217;t know what will happen if you sprinkle enum values in random places throughout your dynamic query. Work on My Machine, your mileage may vary, etc. etc. etc.</p>
<p><strong>1.</strong> <a href="http://msdn2.microsoft.com/en-us/vcsharp/bb894665.aspx">Download the sample.</a></p>
<p><strong>2.</strong> Crack open the Dynamic.cs source file. It&#8217;s scary, but you can do it. Modify it like so (I added the &quot;if (ParseEnumType&#8230;&quot;</p>
<pre class="c#" name="code">Expression ParseIdentifier() {
    ValidateToken(TokenId.Identifier);
    object value;
    if (keywords.TryGetValue(token.text, out value)) {
        if (value is Type) return ParseTypeAccess((Type)value);
        if (value == (object)keywordIt) return ParseIt();
        if (value == (object)keywordIif) return ParseIif();
        if (value == (object)keywordNew) return ParseNew();
        NextToken();
        return (Expression)value;
    }
    if (symbols.TryGetValue(token.text, out value) ||
        externals != null &amp;&amp; externals.TryGetValue(token.text, out value)) {
        Expression expr = value as Expression;
        if (expr == null) {
            expr = Expression.Constant(value);
        }
        else {
            LambdaExpression lambda = expr as LambdaExpression;
            if (lambda != null) return ParseLambdaInvocation(lambda);
        }
        NextToken();
        return expr;
    }
    // ADD THIS IF STATEMENT
    if (ParseEnumType(out value))
    {
        Expression expr = Expression.Constant(value);
        NextToken();
        return expr;
    }
    if (it != null) return ParseMemberAccess(null, it);
    throw ParseError(Res.UnknownIdentifier, token.text);
}</pre>
<p><strong>3.</strong> Add the definition for ParseEnumType. This little bit of nastiness is essentially doing a look-ahead to resolve a type name, since most of the parser&#8217;s rules are built to process more contextual information (such as a property name of a type, etc.) In our case, we need to attempt to match &quot;Foo.Foo.Foo&quot; to a type name, and if it doesn&#8217;t end up resolving, we need to reset the parser back to the beginning of &quot;Foo&quot; to continue parsing.</p>
<pre class="c#" name="code">bool ParseEnumType(out object value)
{
    value = null;

    ValidateToken(TokenId.Identifier);
    Type enumType = null;
    int position = token.pos;
    string typeName = token.text;
    while (enumType == null)
    {
        // Loop until we stop processing identifiers and/or dots
        enumType = Type.GetType(typeName, false, true);
        if (enumType == null)
        {
            NextToken();
            if (token.id == TokenId.Dot)
            {
                typeName += token.text;
                NextToken();
                if (token.id == TokenId.Identifier)
                {
                    typeName += token.text;
                }
                else
                {
                    break;
                }
            }
            else
            {
                break;
            }
        }
    }

    if ((enumType != null) &amp;&amp; IsEnumType(enumType))
    {
        NextToken();
        ValidateToken(TokenId.Dot, Res.DotExpected);
        NextToken();
        ValidateToken(TokenId.Identifier, Res.IdentifierExpected);
        value = Enum.Parse(enumType, token.text, true);
        return true;
    }
    else
    {
        SetTextPos(position);
        NextToken();
    }

    return false;
}</pre>
<p><strong>4.</strong> Add an error &quot;resource&quot; string (but not really a true resource string) to the &quot;Res&quot; static class. We added a new condition, so we need an error message to match.</p>
<pre class="c#" name="code">public const string DotExpected = &quot;'.' expected&quot;;</pre>
<p>Voila! Make sure your enum values are fully-qualified type names and you&#8217;ll be good to go.</p>
<p>Hopefully this works for you as well as it did for me, and I have to say I can&#8217;t believe I couldn&#8217;t find this on the &#8216;net, as I imagine this is a very common use-case.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/aaronlerch?a=mtRL0RCP"><img src="http://feeds.feedburner.com/~f/aaronlerch?i=mtRL0RCP" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/aaronlerch?a=NP7fJsWl"><img src="http://feeds.feedburner.com/~f/aaronlerch?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/aaronlerch?a=HUaSypAn"><img src="http://feeds.feedburner.com/~f/aaronlerch?i=HUaSypAn" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/aaronlerch?a=3ZHQ96Fc"><img src="http://feeds.feedburner.com/~f/aaronlerch?i=3ZHQ96Fc" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/aaronlerch/~4/GuPfw2sI3PA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.aaronlerch.com/blog/2008/12/15/case-insensitive-string-comparisons-with-linq-dynamic-query/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.aaronlerch.com/blog/2008/12/15/case-insensitive-string-comparisons-with-linq-dynamic-query/</feedburner:origLink></item>
		<item>
		<title>Run ASP.NET MVC on Windows Azure</title>
		<link>http://feedproxy.google.com/~r/aaronlerch/~3/o1sJttqAaM0/</link>
		<comments>http://www.aaronlerch.com/blog/2008/11/01/run-aspnet-mvc-on-windows-azure/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 05:23:31 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[asp.net mvc]]></category>
		<category><![CDATA[azure]]></category>

		<guid isPermaLink="false">http://www.aaronlerch.com/blog/2008/11/01/run-aspnet-mvc-on-windows-azure/</guid>
		<description><![CDATA[If you’ve purposefully been ignoring the announcements out of PDC, I don’t blame you one bit. Everybody knew it would be the unveiling of Microsoft’s “cloud computing” initiative, and just about the only thing we didn’t know was the official name of it: Windows Azure. And of course I pronounce it wrong every time (I [...]]]></description>
			<content:encoded><![CDATA[<p>If you’ve purposefully been ignoring the announcements out of PDC, I don’t blame you one bit. Everybody knew it would be the unveiling of Microsoft’s “cloud computing” initiative, and just about the only thing we didn’t know was the official name of it: Windows Azure. And of course I pronounce it wrong every time (I say “ah-<em>jour</em>”, as in “soup-de-jour”). It’s hard to call it “initiative” when they’re the 3rd one to bring a product to the table. <img src='http://www.aaronlerch.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>One thing I was looking forward to was hearing about the ASP.NET MVC story on Azure. So color me surprised when I found out there wasn’t one. Since ASP.NET MVC is bin-deployable it shouldn’t be impossible, and doing some quick searches didn’t retrieve any results showing anybody else having tried this. Of course <em>later</em> I discovered that Phil and Eilon had whipped up a sample app that ran ASP.NET MVC on Azure, but was pleased to find out that the <a href="http://blogs.msdn.com/jnak/archive/2008/10/28/asp-net-mvc-projects-running-on-windows-azure.aspx">downloadable sample app</a> didn’t work. In fact, it seemed to just be MVC stuff slapped into a WebRole project. (I’m guessing something got “lost in translation” since it wasn’t Phil or Eilon that posted the code.)</p>
<p>Anyway, here’s how you can get ASP.NET MVC up and running on Azure. I’ve created a Visual Studio template for this to make it easy to set up &#8211; <a href="http://s3.amazonaws.com:80/aaronlerch.com/files/ASP_NET_MVC_Web_Role.zip"><strong>download it here</strong></a>. To avoid distributing code that isn’t my own (i.e. Windows Azure SDK Samples) there are a few steps you’ll have to take. I’m presuming that you’ve already installed the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=BB893FB0-AD04-4FE8-BB04-0C5E4278D3E9&amp;displaylang=en">Windows Azure SDK</a> and the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=63D0D248-1B08-4F7D-ABDE-62EB75CB1E69&amp;displaylang=en">Azure Visual Studio tools</a>.</p>
<p>One thing that running a web application “in the cloud” means is that you can instantly scale higher by adding more “instances”. This means the leaky-as-a-sieve abstraction of “session state” isn’t immediately available (finally!) since any given HTTP request could be going to a different server. The default session state provider for ASP.NET is an in-memory provider. This assumes that every request comes to the same physical machine. Session state providers have varied in their reliability and handling of scalability, but the other built-in providers include an out-of-proc provider (still same machine, but more resilient to IIS going up and down) and a SQL Server provider. None of these are enabled on the Azure platform, for good reason.</p>
<p>The limitation of zero session state wouldn’t matter except that ASP.NET MVC includes the concept of “Temp Data”, which is data persisted in one request and made available to <em>the next request only</em>. By default, MVC uses the session to store this data.</p>
<p><em>Aside: like it does everywhere else, ASP.NET MVC allows you to swap out default implementations for TempData persistence. A better solution than what I have below is to specifically implement a TempDataProvider that uses the Azure data storage capabilities. Look for that soon. <img src='http://www.aaronlerch.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </em></p>
<p>Fortunately for us the Windows Azure SDK includes some “samples”, including full implementations of membership, profile, and session providers built on the Azure data storage platform. So let’s hack those in to fulfill the default requirements of ASP.NET MVC. The only thing that I’ll say about this is that much of this stuff had better be baked into the SDK/platform by the time it goes GA. This is just a CTP, and Microsoft has been doing better at earlier community releases, so I’ll cut them some slack. <img src='http://www.aaronlerch.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  But this is <strong>way</strong> to much work to be a reasonable shipped solution.</p>
<h4>Unzip the “samples.zip” file in the Azure SDK and build the “AspProviders” application.</h4>
<p><img src="http://s3.amazonaws.com:80/aaronlerch.com/images/asp_net_azure_sample_location.png" /></p>
<p>They’ve conveniently included “buildme.cmd” batch files, but I built the application using Visual Studio since I like to see more of “what’s going on” (even though I really don’t see more, per se).</p>
<p><img src="http://s3.amazonaws.com:80/aaronlerch.com/images/asp_net_azure_build_sample.png" /></p>
<h4>Create the required tables in the Azure Development Storage.</h4>
<p>Open the Azure SDK command prompt under your start menu, and navigate to the directory containing the AspProviders output. Run the command “devtablegen” passing in the assembly name “AspProviders.dll”. This command creates the appropriate database structures to persist objects that meet certain criteria. Run devtablegen with no parameters for a short description, or check out the documentation for more info as well.</p>
<p><img src="http://s3.amazonaws.com:80/aaronlerch.com/images/asp_net_azure_devtablegen.png" /></p>
<p>You’ll get a confirmation window that displays progress and shows that the table was created successfully.</p>
<h4>Start the Development Storage service.</h4>
<p>By now, the storage service should be running, but you’ll need to explicitly enable its endpoints. Open the UI from the system tray icon (<img src="http://s3.amazonaws.com:80/aaronlerch.com/images/asp_net_azure_development_storage_icon.png" />), and click “Start”. If you’ve never started it before, it will ask you for the name of the database – select “AspProviders”.</p>
<p><img src="http://s3.amazonaws.com:80/aaronlerch.com/images/asp_net_azure_development_storage.png" /></p>
<p><img src="http://s3.amazonaws.com:80/aaronlerch.com/images/asp_net_azure_database_selection.png" /></p>
<h4>Create a new Cloud Service and add an “ASP.NET MVC Web Role” project.</h4>
<p><a href="http://s3.amazonaws.com:80/aaronlerch.com/files/ASP_NET_MVC_Web_Role.zip"><strong>Download the Visual Studio template I created here.</strong></a> Import the template by copying the downloaded .zip file to “My Documents\Visual Studio 2008\Templates\Project Templates” (or whatever you have specified in Tools – Options – Projects and Solutions – General). Create a new “Blank Cloud Service” project.</p>
<p>&#160;<img src="http://s3.amazonaws.com:80/aaronlerch.com/images/asp_net_azure_cloud_service.png" /></p>
<p>Add a new “ASP.NET MVC Web Role” project using the installed template.</p>
<p><img src="http://s3.amazonaws.com:80/aaronlerch.com/images/asp_net_azure_web_role.png" /></p>
<p>Your VS solution should now approximate this:</p>
<p><img src="http://s3.amazonaws.com:80/aaronlerch.com/images/asp_net_azure_project_layout.png" /></p>
<p>Under the “Cloud Service” project, right-click on the “Roles” folder and select “Add &gt; Web Role Project in solution…” and select the web role project we just added.</p>
<h4>Cleanup</h4>
<p>Because I can’t distribute the compiled version of the sample app, and because the location of it on your drive depends entirely on your personal preferences, you’ll have to re-add the references manually. From the ASP.NET MVC Web Role project we added, delete the references to AspProviders and StorageClient</p>
<p><img src="http://s3.amazonaws.com:80/aaronlerch.com/images/asp_net_azure_references.png" /></p>
<p>and re-add the references pointing to the assemblies we built above.</p>
<p>Press F5, and you’re up and running the default ASP.NET MVC sample app on the Windows Azure platform! From there the sky’s the limit. Or maybe “the cloud’s the limit”?</p>
<p><img src="http://s3.amazonaws.com:80/aaronlerch.com/images/asp_net_azure_final.png" /></p>
<div class="wlWriterEditableSmartContent" id="scid:C16BAC14-9A3D-4c50-9394-FBFEF7A93539:9393a903-6e50-4089-877b-3a9699fc7c80" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"><a href="http://www.dotnetkicks.com/kick/?url=http://www.aaronlerch.com/blog/2008/11/01/run-aspnet-mvc-on-windows-azure/"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://www.aaronlerch.com/blog/2008/11/01/run-aspnet-mvc-on-windows-azure/" border="0" alt="kick it on DotNetKicks.com" /></a></div>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/aaronlerch?a=fKtsThzH"><img src="http://feeds.feedburner.com/~f/aaronlerch?i=fKtsThzH" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/aaronlerch?a=ozMF1n9m"><img src="http://feeds.feedburner.com/~f/aaronlerch?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/aaronlerch?a=7FBtiG4L"><img src="http://feeds.feedburner.com/~f/aaronlerch?i=7FBtiG4L" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/aaronlerch?a=tAUMnLhW"><img src="http://feeds.feedburner.com/~f/aaronlerch?i=tAUMnLhW" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/aaronlerch/~4/o1sJttqAaM0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.aaronlerch.com/blog/2008/11/01/run-aspnet-mvc-on-windows-azure/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		<feedburner:origLink>http://www.aaronlerch.com/blog/2008/11/01/run-aspnet-mvc-on-windows-azure/</feedburner:origLink></item>
		<item>
		<title>The Aaron and Mike Show</title>
		<link>http://feedproxy.google.com/~r/aaronlerch/~3/W0F4r0QFmlY/</link>
		<comments>http://www.aaronlerch.com/blog/2008/10/24/the-aaron-and-mike-show/#comments</comments>
		<pubDate>Sat, 25 Oct 2008 01:48:03 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[aaron and mike show]]></category>

		<guid isPermaLink="false">http://www.aaronlerch.com/blog/2008/10/24/the-aaron-and-mike-show/</guid>
		<description><![CDATA[I wasn’t going to say anything until we had another show or two under our belt (for your sake, poor innocent reader!) but Mike let the cat out of the bag. He’s much crueler than I am.  
I recently heard a reading of an essay where the author said that the reason children create [...]]]></description>
			<content:encoded><![CDATA[<p>I wasn’t going to say anything until we had another show or two under our belt (for your sake, poor innocent reader!) but <a href="http://ilikeellipses.com/">Mike</a> let the <a href="http://ilikeellipses.com/2008/10/24/the-aaron-and-mike-show-1/">cat out of the bag</a>. He’s much crueler than I am. <img src='http://www.aaronlerch.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I recently heard a reading of an essay where the author said that the reason children create so much art is that <em>they don’t know that they’re bad at it</em>. That’s so true. And yet I love walking through my 4-year old daughter’s pre-school looking at the dozens and dozens of masterpieces posted on the walls.</p>
<p>There is something about society, peer pressure, fear of failure, etc. that keeps us from trying things because we’re not good at it. “I wish I was good at that,” we tell ourselves. But we get into a race condition where we demand excellence from ourselves before we can start, yet we need to start to achieve that excellence.</p>
<p>Enough psychobabble &#8211; what am I getting at, anyway? It’s the <a href="http://www.aaronlerch.com/blog/live/">Aaron and Mike Show</a>. My friend and coworker Mike and I decided we’d take no more than 15 minutes on a Thursday afternoon (4PM EST) and broadcast a “show” <em>LIVE</em> right from my office. We’ll talk about software and the craft of building software. Imagine it like an even shorter <a href="http://www.hanselminutes.com/">Hanselminutes</a>. Not the Hanselminutes of late, which are just interviews, nay, it’s more like the old-school Hanselminutes from way back yonder when Scott was building products for <a href="http://www.corillian.com/">Corillian</a> and talked about the real development challenges he faced every day. <em>(Both styles of Hanselminutes are good, but each serves/served a different purpose.)</em></p>
<p>Mike and I will be talking about the development challenges we run across every day, as well as the kinds of things we are continually doing to improve our skill at the craft of software. It’ll be hard to fit it into 15 minutes but we will do our best. Each show will be recorded, so if you can’t make it to the live show, you can still see the recorded version later, and I’ll put up a blog post for each show with notes, follow-ups, etc.</p>
<p>Our first show (<a href="http://www.aaronlerch.com/blog/live/show-1/">view it here</a>) was SPECTACULAR! Just look at the kind of feedback we received:</p>
<blockquote><p>I expect this to be spectacularly lame <img src='http://www.aaronlerch.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  (getting popcorn)<br />
- <a href="http://twitter.com/subdigital/statuses/972552902">subdigital</a></p>
<p>thanks for your first show! Looks nice, a bit flaky though. But the effort is much appreciated. We all should start doing this!<br />
The deep insights you guys raised OTOH completely made up for the flakiness<br />
- <a href="http://twitter.com/azuidhof/status/973502317">azuidhof</a> (<a href="http://twitter.com/azuidhof/status/973578715">2nd tweet</a>)</p></blockquote>
<p>Okay, so it was a little rough. <img src='http://www.aaronlerch.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  But we’re new at this, we had fun doing it, and I’m looking forward to getting better as we go along.</p>
<p><a href="http://www.ustream.tv/flash/video/808022">View the video here</a> </p>
<p>Please leave us feedback with ideas of what you’d like us to talk about. You can leave a comment on this post if you like. We’ll be having the occasional guest on the show (our co-workers) to share something going on in their world of software.</p>
<p><strong>My main question for you is, will you still respect me in the morning? <img src='http://www.aaronlerch.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </strong></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/aaronlerch?a=eL7CGW2k"><img src="http://feeds.feedburner.com/~f/aaronlerch?i=eL7CGW2k" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/aaronlerch?a=kzMKcao8"><img src="http://feeds.feedburner.com/~f/aaronlerch?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/aaronlerch?a=zNp6cIFz"><img src="http://feeds.feedburner.com/~f/aaronlerch?i=zNp6cIFz" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/aaronlerch?a=1wfaC4AP"><img src="http://feeds.feedburner.com/~f/aaronlerch?i=1wfaC4AP" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/aaronlerch/~4/W0F4r0QFmlY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.aaronlerch.com/blog/2008/10/24/the-aaron-and-mike-show/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.aaronlerch.com/blog/2008/10/24/the-aaron-and-mike-show/</feedburner:origLink></item>
		<item>
		<title>Indy Tech Fest Slides</title>
		<link>http://feedproxy.google.com/~r/aaronlerch/~3/uQV_WchSbCU/</link>
		<comments>http://www.aaronlerch.com/blog/2008/10/06/indy-tech-fest-slides/#comments</comments>
		<pubDate>Mon, 06 Oct 2008 06:06:37 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[asp.net mvc]]></category>
		<category><![CDATA[community]]></category>

		<guid isPermaLink="false">http://www.aaronlerch.com/blog/2008/10/06/indy-tech-fest-slides/</guid>
		<description><![CDATA[I really enjoyed giving my talk on ASP.NET MVC at Indy Tech Fest this year. Thanks to all who came! I think there were 75-100 people there.
A poll at the beginning showed that most people in attendance had done some sort of web development, about a third had done ASP.NET development, and 2 people had [...]]]></description>
			<content:encoded><![CDATA[<p>I really enjoyed giving my talk on ASP.NET MVC at Indy Tech Fest this year. Thanks to all who came! I think there were 75-100 people there.</p>
<p>A poll at the beginning showed that most people in attendance had done some sort of web development, about a third had done ASP.NET development, and 2 people had worked with ASP.NET MVC. The most challenging thing was that almost everybody was unfamiliar with the MVC pattern. And yet again I learned the difference between a master and a wanna-be. A master can take complex principles and concepts and express them in a simple form that people can immediately understand. I, on the other hand, cannot. I seemed to struggle with getting the “core concepts” of ASP.NET MVC across in a way that was clear and unambiguous.</p>
<p>I’ve created a slideshare presentation with the slides. It’s an overview, and I only had time to cover a few aspects of it, but I’m still sure I was off on a few concepts – if you notice something, leave a comment so I can learn!</p>
<div id="__ss_638175" style="width: 425px; text-align: left"><a title="Indy Tech Fest 2008 - ASP.NET MVC" style="display: block; margin: 12px 0px 3px; font: 14px helvetica,arial,sans-serif; text-decoration: underline" href="http://www.slideshare.net/aaronlerch/indy-tech-fest-2008-aspnet-mvc-presentation?type=powerpoint">Indy Tech Fest 2008 &#8211; ASP.NET MVC</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=indytechfest-2008-aspnet-mvc-published-1223261777987020-9&amp;stripped_title=indy-tech-fest-2008-aspnet-mvc-presentation" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><embed src="http://static.slideshare.net/swf/ssplayer2.swf?doc=indytechfest-2008-aspnet-mvc-published-1223261777987020-9&amp;stripped_title=indy-tech-fest-2008-aspnet-mvc-presentation" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object></div>
<p>Here links to various MVC resources to get you started with ASP.NET MVC:</p>
<p>- <a href="http://www.codeplex.com/aspnet"><strong>Download ASP.NET MVC from Codeplex</strong></a>     <br />- <a href="http://mvccontrib.com/"><strong>MVCContrib – community contributions/extensions to ASP.NET MVC</strong></a>     <br />- <a href="http://codecampserver.com/"><strong>CodeCampServer – a slightly-out-of-date-but-still-good reference implementation</strong></a>     <br />- <a href="http://www.asp.net/mvc/">Official ASP.NET MVC site (lots of links to resources)</a>     <br />- <a href="http://forums.asp.net/1146.aspx">ASP.NET MVC Forums – a lot of questions asked and answers given</a>     <br />- <a href="http://weblogs.asp.net/scottgu/archive/tags/MVC/default.aspx">ScottGu’s MVC posts</a>     <br />- <a href="http://haacked.com/">Phil Haack is the ASP.NET MVC Program Manager</a>     <br />- <a href="http://weblogs.asp.net/stephenwalther/archive/tags/ASP.NET+MVC/default.aspx">Stephen Walther has done many posts on ASP.NET MVC</a>     <br />- <a href="http://technorati.com/tag/aspnetmvc">Blog posts tagged “aspnetmvc” on Technorati</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/aaronlerch?a=hTmzWsd1"><img src="http://feeds.feedburner.com/~f/aaronlerch?i=hTmzWsd1" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/aaronlerch?a=VRfQznEt"><img src="http://feeds.feedburner.com/~f/aaronlerch?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/aaronlerch?a=M3Sz6QeU"><img src="http://feeds.feedburner.com/~f/aaronlerch?i=M3Sz6QeU" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/aaronlerch?a=TjQu6DC0"><img src="http://feeds.feedburner.com/~f/aaronlerch?i=TjQu6DC0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/aaronlerch/~4/uQV_WchSbCU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.aaronlerch.com/blog/2008/10/06/indy-tech-fest-slides/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.aaronlerch.com/blog/2008/10/06/indy-tech-fest-slides/</feedburner:origLink></item>
	</channel>
</rss>
