Thursday, March 31, 2011

Monads! European Virtual ALT.NET. Video is now available

Thanks to the excellent Jan Van Ryswyck, the video of my EVAN talk is now on Vimeo here:

http://vimeo.com/21705972

It’s very similar to the DDD talk video that I posted before, but I think a little more polished. It’s much easier to follow in this format too.

I start off with a brief introduction and history of Monads, but spend most of the talk deriving a Monad by attempting to do function composition with two Maybe returning functions. I briefly overview the differences between C#, F# and Haskell Monad handling at the end.

Check out my series on Monads here:

http://mikehadlow.blogspot.com/2011/01/monads-in-c1-introduction.html

Sunday, March 27, 2011

Monads! European Virtual ALT.NET Tuesday 29th March

Jan Van Ryswyck has very kindly invited me to rant at length on the subject of Monads. I’m going to be giving an hour long presentation for the European Virtual ALT.NET this Tuesday. This will be a first for me, I haven’t attempted an on-line presentation before, so I’m very interested to see how it goes.

The talk is going to be very similar to the Monad talk I gave at DDD9, but hopefully I’ve improved the flow and code examples, so it might make more sense. The full announcement (and details about how to join in) are here:

http://europevan.blogspot.com/2011/03/mike-hadlow-on-monads-on-29-march-2011.html

See you on Tuesday!

Wednesday, March 16, 2011

7000 Concurrent Connections With Asynchronous WCF

It’s rare that a web service has some intensive processor bound computation to execute. Far more common for business applications, is a web service that executes one or more IO intensive operations. Typically our web service would access a database over the network, read and write files, or maybe call another web service. If we execute these operations synchronously, the thread that processes the web service request will spend most of its time waiting on IO. By executing IO operations asynchronously we can free the thread processing the request to process other requests while waiting for the IO operation to complete.

In my experiments with a simple self-hosted WCF service, I’ve been able to demonstrate up to 7000 concurrent connections handled by just 12 threads.

Before I show you how to write an asynchronous WCF service, I want to clear up the commonly held misconception (yes, by me too until a year or so ago), that asynchronous IO operations spawn threads. Many of the APIs in the .NET BCL (Base Class Library) provide asynchronous versions of their methods. So, for example, HttpWebRequest has a BeginGetResponse / EndGetResponse method pair alongside the synchronous method GetResponse. This pattern is called the Asynchronous Programming Model (APM). When the APM supports IO operations, they are implemented using an operating system service called IO Completion Ports (IOCP). IOCP provides a queue where IO operations can be parked while the OS waits for them to complete, and provides a thread pool to handle the completed operations. This means that in-progress IO operations do not consume threads.

The WCF infrastructure allows you to define your operation contracts using APM. Here’s a contract for a GetCustomer operation:

[ServiceContract(SessionMode = SessionMode.NotAllowed)]
public interface ICustomerService
{
[OperationContract(AsyncPattern = true)]
IAsyncResult BeginGetCustomerDetails(int customerId, AsyncCallback callback, object state);
Customer EndGetCustomerDetails(IAsyncResult asyncResult);
}

Essentially ‘GetCustomerDetails’ takes a customerId and returns a Customer. In order to create an asynchronous version of the contract I’ve simply followed the APM pattern and created a BeginGetCustomerDetails and an EndGetCustomerDetails. You tell WCF that you are implementing APM by setting AsyncPattern to true on the operation contract.

The IAsyncResult that’s returned from the ‘begin’ method and passed as an argument to the ‘end’ method links the two together. Here’s a simple implementation of IAsyncResult that I’ve used for these experiments, you should be able to use it for any asynchronous WCF service:

public class SimpleAsyncResult<T> : IAsyncResult
{
private readonly object accessLock = new object();
private bool isCompleted = false;
private T result;

public SimpleAsyncResult(object asyncState)
{
AsyncState = asyncState;
}

public T Result
{
get
{
lock (accessLock)
{
return result;
}
}
set
{
lock (accessLock)
{
result = value;
}
}
}

public bool IsCompleted
{
get
{
lock (accessLock)
{
return isCompleted;
}
}
set
{
lock (accessLock)
{
isCompleted = value;
}
}
}

// WCF seems to use the async callback rather than checking the wait handle
// so we can safely return null here.
public WaitHandle AsyncWaitHandle { get { return null; } }

// We will always be doing an async operation so completed synchronously should always
// be false.
public bool CompletedSynchronously { get { return false; } }

public object AsyncState { get; private set; }
}

Now we’ve got an AsyncResult we can implement our APM based service by implementing ICustomerService:

[ServiceBehavior(
InstanceContextMode = InstanceContextMode.PerCall,
ConcurrencyMode = ConcurrencyMode.Multiple)]
public class CustomerService : ICustomerService
{
public const int DelayMilliseconds = 10000;

public IAsyncResult BeginGetCustomerDetails(int customerId, AsyncCallback callback, object state)
{
var asyncResult = new SimpleAsyncResult<Customer>(state);

// mimic a long running operation
var timer = new System.Timers.Timer(DelayMilliseconds);
timer.Elapsed += (_, args) =>
{
asyncResult.Result = GetCustomer(customerId);
asyncResult.IsCompleted = true;
callback(asyncResult);
timer.Enabled = false;
timer.Close();
};
timer.Enabled = true;
return asyncResult;
}

public Customer EndGetCustomerDetails(IAsyncResult asyncResult)
{
return ((SimpleAsyncResult<Customer>) asyncResult).Result;
}

private static Customer GetCustomer(int customerId)
{
return new Customer(customerId, "Mike_" + customerId);
}
}

We’re mimicking a long running IO operation by using a timer. I believe that the Timer also uses an IO completion port, but don’t quote me on that. When WCF invokes BeginGetCustomerDetails we first create a new SimpleAsyncResult with WCF’s state object. WCF will pass the AsyncResult to the EndGetCustomerDetails method when the timer completes, so we can use it to pass any response state. In our case this is an instance of Customer.

Next we set up a Timer and attach a closure to the Elapsed event. When the timer’s Elapsed event fires we create a customer instance, pass it to our AsyncResult and then pass the AsyncResult to WCF’s callback function.

After the BeginGetCustomerDetails method completes, WCF returns its thread back to the WCF thread pool so that it can service other requests. Ten seconds later, the operating system posts an item on to the IOCP queue, a thread from the pool picks up the item and executes the continuation. This in turn calls WCF’s callback which in turn executes EndGetCustomerDetails. WCF then packages up the Customer as a SOAP response and returns it to the client.

Only a tiny fraction of that 10 seconds has actually occupied a thread, so we should be able to make thousands of concurrent calls to this service.

In my tests, this service has been able to handle a little over 7000 concurrent connections.

The code is here: https://github.com/mikehadlow/Mike.AsyncWcf

Just follow the README instructions to run the tests and try it out for yourself.

Wednesday, March 02, 2011

WebStresser: A very simple web load testing tool

I’ve been doing some experiments recently with WCF, seeing how much load I can throw at different configurations. I’m especially interested in seeing what difference async web services can make with IO intensive operations. One problem I had was finding a good HTTP load tool. I tried to get WCAT working, but found it complex and hard to understand. It also gives almost no feedback at all when you get something wrong.

In the end I wrote my own little load tool around WebRequest. It’s almost trivial, but there are few little hoops you need to jump through in order to make it work. I’ve wrapped it up as a little console application, WebStresser. You can get the source from github here:

https://github.com/mikehadlow/WebStresser

Or download a precompiled binary which requires .NET 3.5 or greater to work. It’s also reported to work fine on Mono:

https://github.com/downloads/mikehadlow/WebStresser/WebStresser.zip

To use it, just run it with a minimum of a URL:

WebStresser -u=http://localhost:5401/

Which outputs:

Starting test...
Completed: 0 Faulted: 0 Connections: 1
Completed All 1
Faulted 0
Elapsed ms 2,001
Calls per second 0
Avergate call duration ms 1,127

By default it just executes a single GET request to the given URI. If you want to see the response, add the –r option:

webstresser -u=http://localhost:5401/ -r

Which outputs:

Starting test...
Completed: 0 Faulted: 0 Connections: 1

http://localhost:5401/
Status: 200, OK
X-AspNetMvc-Version: 3.0
Connection: Close
Content-Length: 7259
Cache-Control: private
Content-Type: text/html; charset=utf-8
Date: Wed, 02 Mar 2011 21:49:37 GMT
Server: ASP.NET Development Server/10.0.0.0
X-AspNet-Version: 4.0.30319

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3. .... etc

To run a load test, just tell it how many requests to make with the –i option, and the delay, in milliseconds, between each request with the –t option. Here I’m running 100 requests 20 ms apart:

webstresser -u=http://localhost:5401/ -i=100 -t=20

Finally here’s an example calling a SOAP web service. Note the SOAPAction header and the –p option that points to a file with the postdata:

webstresser -u=http://mike-2008r2:8123/proxy -m=POST -i=100 -t=10 -p=postdata.txt 
-H=SOAPAction:http://tempuri.org/ICustomerService/GetCustomerDetails

For help:
webstresser -h

Options
-?, -h, --help
-u, --uri=VALUE REQUIRED: The URI you want to call
-m, --method=VALUE The HTTP method. Default is GET
-i, --iterations=VALUE Number of iterations to run, default is 1
-t, --interval=VALUE Iterval between each call in milliseconds, default
is 10000
-p, --postdata=VALUE Path to file containing post data
-r, --responses Print responses
-k, --keepalive KeepAlive header value (true or false), default is
true
-a, --accept=VALUE Accept header value, default is 'text/xml'
-c, --contenttype=VALUE ContentType header value, default is 'text/xml;
charset="utf-8"'
-z, --timeout=VALUE Timeout in milliseconds, default is 10000
-H[=VALUE1:VALUE2] Add a header to the request. e.g: -H MyHeader=
MyValue

I’m using the excellent Mono.Options library to do command line processing. It makes putting this kind of tool together very easy.

Happy stressing!

Tuesday, February 22, 2011

Brighton ALT.NET show and tell night videos

Back on the 1st February we had a show and tell night at Brighton ALT.NET – Thanks to Keith Bloom, who brought his video camera along and then went through the painful process of uploading them all to Vimeo, we can now present the show and tell videos:

Steve Mason - N2 CMS

A quick tour of the best open source CMS on the planet. Homepage - http://n2cms.com/ Source code - http://github.com/n2cms/n2cms/ (the Google code & codeplex repositories are old & unused) Discussions - http://n2cms.codeplex.com/discussions

Andrew Cherry - Socket Machine

A .NET server toolkit that you can use to build any socket based server on .NET with a very nice fluent API. The source will be opened up soon on Github, for now follow @socketmachine - announcements etc. will always be there from now on. Code will be published under the xyncro org on Github (https://github.com/xyncro) but be aware that there is nothing currently there now - this is intentional.

Jay Kannan - Kinect in .NET

Using the Kinect to control .NET applications. the demo concentrated on a Game Environment using the XNA platform and 3D physics for creating and bouncing bubbles around the screen. a long way to go to make it usable. the Kinect is clearly the best Augmented reality / motion control platform of choice for Kiosk makers and for public user interaction. look at the links below for more information. Kinect Hacks. PrimeSense OpenNI - this is the official library from the CHipset guys that I'm using. OpenKinect. Code Laboratories.

Michael Steele - Netduino

blog My introductory blog for netduino - will update with the burglar alarm & operation game
Netduino forum
.Net Micro Framework
tinyclr Fez community website - Another board running .Net Micro Framework
Scott Hanselman Micro Framework/Netduino podcasts
Build Brighton meet every Thursday at The Skiff to tinker with electronics.

Me - Monads in C#

This is a very compressed, and probably meaningless 15 minute version of my hour long DDD9 talk. Session code on github. The Monad Wikipedia page is excellent, if somewhat intimidating. The references and external links are an excellent starting point for further investigation.

Paul Hazells - Can twitter predict the stock market?

Unfortunately, Keith's video recorder died by this point, so we don't have Paul's excellent session. Very sorry Paul. But here are the links:

http://aws.amazon.com/free/ - AWS Free Usage Tier
http://nodejs.org/ - node.js
https://github.com/isaacs/npm - npm (node package manager)
https://github.com/technoweenie/twitter-node - twitter-node
https://github.com/indexzero/forever - forever
http://omnipotent.net/jquery.sparkline/ - sparklines (for the graphs)
http://html5boilerplate.com/ I forgot to mention the HTML5 boilerplate which I've also used. I saw a few of the group at the DDD9 talk on this so thought it might be of interest. I'd definitely recommend it for new projects, especially if you need to support older browsers.

If you have any questions or comments, please do not hesitate to ask me either at a meeting or via twitter: @paulhazells

Thursday, February 17, 2011

Monads in C#-8. Video of my DDD9 Monad talk

This is the eighth part of my Monad series. See the introduction for a list of all the posts.

You can find the code for this post on GitHub here.

Last month I gave a talk at DDD9 loosely based on this series: Monads! What are they and why should I care.

Note: The talk (and audio) starts at 6 minutes into the video.

Mike Hadlow - Monads! What are they and why should I care? - DeveloperDeveloperDeveloper 9 from Phil Winstanley on Vimeo.

Enjoy!

Tuesday, February 15, 2011

Delegates make great container components

The problem with object oriented languages is that you often have to wrap up single functions in a class even when there’s no real reason for that class to exist. This is especially true for many ‘service’ classes. For example, for a long time I used to have something like this in most of my projects:

public interface IDateProvider
{
DateTime Now();
}
public class DateProvider : IDateProvider
{
public DateTime Now()
{
return DateTime.Now();
}
}

I would register my DateProvider with Windsor like this:

container.Regisgter(
Component.For<IDateProvider>().ImplementedBy<DateProvider>()
);

Being able to set the current time in unit tests is essential if you’re doing any kind of logic that does date computations, and this served me well. But it’s a lot of boiler plate just to get the current date. It also means that I have to build a mock IDateProvider for my unit tests and set stubs on it – more irritating boiler plate.

But C# is also quite a good functional language and Windsor deals with delegates just as easily as it deals with interfaces. These days I no longer have an IDateProvider, but just a simple delegate:

public delegate DateTime Now();

Which I register like this:

container.Register(
Component.For<Now>().Instance(() => DateTime.Now),
);

Now any component that needs to know the current DateTime value simply has a dependency on the Now delegate:

public class MyComponent
{
private readonly Now now;
public MyComponent(Now now)
{
this.now = now;
}
public void DoSomething()
{
var currentTime = now();
....
}
}

And it’s really easy to stub out for unit tests:

var now = new DateTime(2010, 2, 15);
var myComponent = new MyComponent(() => now);
myComponent.DoSomething();

This is also a great way for providing infrastructure services when your infrastructure isn’t IoC container friendly. How about this:

public delegate string CurrentUser();

...

container.Register(
Component.For<CurrentUser>().Instance(() => HttpContext.Current.User.Identity.Name)
);

In some ways delegates are more flexible than interfaces since you don’t have to declare that a particular lambda or method implements the delegate, so long as the signature matches you’re good.

Indeed, if Windsor did currying we could probably remove most of our service classes and simply write our software as static methods. But that’s another blog post ;)

Sunday, February 13, 2011

Using Git alongside other version control systems

I love Git. If you haven’t yet discovered the awesomeness of distributed version control, you are really missing out. Git is now the version control system of choice for a huge number of open source projects. That’s probably got a lot to do with GitHub, the best cloud based version control system on the planet, but the ease with which you can branch and merge with Git is also a major factor.

But even if you’re not building open source software development in the cloud, even if you’re stuck in some enterprise shop with TFS, you can still use the power of Git’s branching and merging to help you get your work done. Because Git is a distributed version control system it makes it trivial to set up a local repository. You can use that local repository create small local branches for particular features and to help you merge them together before you make a big check-in to your corporate VCS.

The trick to getting Git to work well in this scenario is to make sure that Git and your main VCS ignore each other.

For example, I’m still using subversion and Google Code for Suteki Shop. Yes, I know I should move it over to Git and GitHub, but I’m lazy and I quite like the Google Code project page, so I haven’t had the time or the inclination to do it yet. But I use Git locally to manage small changes. To get Git and subversion to ignore each other is pretty easy. Git places its repository in a folder in the root of your project called ‘.git’. I just ask subversion to ignore that folder. Using TortoiseSVN you do it like this:

svnignore

Getting Git to ignore subversion is similarly easy. Subversion tracks its status using files in an ‘.svn’ folder in each folder under source control, so I simply add ‘.svn’ to my .gitignore file:

Here’s my .gitignore file:

[Oo]bj
[Bb]in
*.user
*.suo
*.[Cc]ache
*.bak
*.ncb
*.log
*.DS_Store
[Tt]humbs.db
_ReSharper.*
.svn

I’m currently working on a stock control addin for Suteki Shop. While I was writing it I came across a bad design choice that I made in the past that stopped me from being able to properly decouple my addin from the core Suteki Shop project. Rather than executing a large refactoring directly in my stock control branch, I created a new branch from master, refactored away my bad design, tested it, merged it back into master and committed it to svn without having had to change or commit my in-progress work on stock control.

This ability to go off on tangents without one piece interfering with another is very powerful. It gives you the confidence to make very radical experimental changes that would have seemed like too much of a commitment previously.

Thursday, February 10, 2011

Monads in C#-7. Turning our parser into a Monad

This is the seventh part of my Monad series. See the introduction for a list of all the posts.

You can find the code for this post on GitHub here.

Do you remember our parser delegate from part 6? If you haven’t read it yet, I’d recommend reviewing it now before reading the rest of this post.

public delegate Maybe<Tuple<T, string>> Parser<T>(string input);

Remember the pain we had to go through to combine these parsers? Let’s try a different approach by turning our parser into a Monad. Up to now we’ve just looked at turning classes or interfaces with a single type parameter into Monads, but we can do just the same with a delegate.

First let’s write a ToParser method. It’s pretty easy we just return a parser that returns our item without consuming any of the input string:

public static Parser<T> ToParser<T>(this T value)
{
return s => new Just<Tuple<T, string>>(Tuple.Create(value, s));
}

Next we need a Bind method. This is a little harder to write, but if we ‘follow the types’ it appears relatively painlessly. Let’s think about the signature of bind, remember this is the same for any Monad:

public static Parser<B> Bind<A, B>(this Parser<A> a, Func<A, Parser<B>> func){}

Now we’ll digest the signature step by step. First let’s look at the return type: Parser<B>.  Remember Parser<B> is a function from a string to a Maybe<Tuple<B, string>>, so we need to return a lambda for that function:

public static Parser<B> Bind<A, B>(this Parser<A> a, Func<A, Parser<B>> func)
{
return s =>
{
// ...
};
}

That lambda needs to return a Maybe<Tuple<B, string>>, we can get one of those by invoking func, getting the returned Parser<B> and invoking that:

public static Parser<B> Bind<A, B>(this Parser<A> a, Func<A, Parser<B>> func)
{
return s =>
{
var bParser = func( ??? );
return bParser( ??? );
};
}

We need an A to pass to func and we can get one of those by invoking the a parser, getting it’s return value and grabbing the A from that:

public static Parser<B> Bind<A, B>(this Parser<A> a, Func<A, Parser<B>> func)
{
return s =>
{
var aMaybe = a(s);
var aResult = aMaybe as Just<Tuple<A, string>>;

// short circuit if parse fails
if (aResult == null) return new Nothing<Tuple<B, string>>();

var aValue = aResult.Value.Item1;

var bParser = func(aValue);
return bParser( ??? );
};
}

Notice how we short circuit the parse if the a parser fails. This means that any combination of parsers will return Nothing if any one of them can’t parse its part of the input string.

Lastly we need a string value to feed to our bParser, which we can get from the a parser result:

public static Parser<B> Bind<A, B>(this Parser<A> a, Func<A, Parser<B>> func)
{
return s =>
{
var aMaybe = a(s);
var aResult = aMaybe as Just<Tuple<A, string>>;

// short circuit if parse fails
if (aResult == null) return new Nothing<Tuple<B, string>>();

var aValue = aResult.Value.Item1;
var sString = aResult.Value.Item2;

var bParser = func(aValue);
return bParser(sString);
};
}

That’s it, we have built a Monadic parser. To use it with Linq syntax we need to write a SelectMany, but that’s a mechanical operation because we already know what it looks like, it’s exactly the same as the Ident<T> SelectMany and the Maybe<T> SelectMany that we’ve already written, except with Parser<T> substituted:

public static Parser<C> SelectMany<A, B, C>(this Parser<A> a, Func<A, Parser<B>> func, Func<A, B, C> select)
{
return a.Bind(aval => func(aval).Bind(bval => select(aval, bval).ToParser()));
}

Now we can write our little Hello World parser in three lines of code:

var helloWorldParser =
from hello in "Hello".Find()
from world in "World".Find()
select new {Hello = hello, World = world};

var result = helloWorldParser("HelloWorld");

Console.WriteLine(result.AsString(x => x.Hello));
Console.WriteLine(result.AsString(x => x.World));

// outputs
// Hello
// World

That is a thing of beauty.

Hopefully you can start to see how Monads can let you simply build some very complex systems.

If you want to dig deeper into Monadic parsers, Nicholas Blumhardt has a very nice implementation called Sprache.

Happy Parsing!

Friday, February 04, 2011

AsmSpy: A little tool to help fix assembly version conflicts

Do you ever get these kinds of messages when you compile your project?

------ Build started: Project: Suteki.Shop.CreateDb, Configuration: Debug x86 ------
No way to resolve conflict between "System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
and "System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35". 
Choosing "System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" arbitrarily.
Consider app.config remapping of assembly "NHibernate, Culture=neutral, PublicKeyToken=aa95f207798dfdb4" 
from Version "3.0.0.2001" [] to Version "3.0.0.4000" 
[D:\Source\sutekishop\Suteki.Shop\packages\NHibernate.3.0.0.4000\lib\NHibernate.dll] to solve conflict and get rid of warning.
Consider app.config remapping of assembly "System.Web.Mvc, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
from Version "2.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 2\Assemblies\System.Web.Mvc.dll] to Version "3.0.0.0" 
[C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll] to solve conflict and get rid of warning.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3247: 
Found conflicts between different versions of the same dependent assembly.
Suteki.Shop.CreateDb -> D:\Source\sutekishop\Suteki.Shop\Suteki.Shop.CreateDb\bin\Debug\Suteki.Shop.CreateDb.exe

The problem is that the build output doesn’t tell me which of my assemblies references version 2.0.0.0 of System.Web.Mvc and which references version 3.0.0.0.

If you’re writing software using lots of 3rd party assemblies like I do, it’s a constant problem. I’ve written a little bit of code that I drag around with me that outputs lists of assemblies that my assemblies reference. I’ve found it very useful for resolving these kinds of issues.

Now I’ve wrapped it up as a little console app, AsmSpy, and put it on github here:

https://github.com/mikehadlow/AsmSpy

Or you can download a zip file of the compiled tool here:

http://static.mikehadlow.com/AsmSpy.zip

How it works:
Simply run AsmSpy giving it a path to your bin directory (the folder where your project's assemblies live). E.g:

AsmSpy D:\Source\sutekishop\Suteki.Shop\Suteki.Shop\bin

It will output a list of all the assemblies referenced by your assemblies. You can look at the
list to determine where versioining conflicts occur.
 
The output looks something like this:

....
Reference: System.Runtime.Serialization
3.0.0.0 by Microsoft.ServiceModel.Samples.XmlRpc
3.0.0.0 by Microsoft.Web.Mvc
4.0.0.0 by Suteki.Shop
Reference: System.Web.Mvc
2.0.0.0 by Microsoft.Web.Mvc
3.0.0.0 by MvcContrib
3.0.0.0 by MvcContrib.FluentHtml
3.0.0.0 by Suteki.Common
2.0.0.0 by Suteki.Common
3.0.0.0 by Suteki.Shop
2.0.0.0 by Suteki.Shop
Reference: System.ServiceModel.Web
3.5.0.0 by Microsoft.Web.Mvc
Reference: System.Web.Abstractions
3.5.0.0 by Microsoft.Web.Mvc
....

You can see that System.Web.Mvc is referenced by 7 assemblies in my bin folder. Some reference
version 2.0.0.0 and some version 3.0.0.0. I can now resolve any conflicts.