Building the source code of ASP.NET (Web API)

There is a lot of activity in the source code of ASP.NET on CodePlex. Because of some bug that has been fixed, I wanted to try out the latest build.

Simply download the latest source code from CodePlex (I used changed set 88372a0b4ab9). Like it is mentioned on CodePlex you have to obtain the NuGet Packages first and after that you can build.

build RestorePackages
build

To test some things out I created a simple console application (inside the same solution) and added the following references with the following code

  • System.Net.Http
  • System.Web.Http
  • System.Web.Http.SelfHost
static void Main(string[] args)
{
   var baseAddress = "http://localhost:7777/";
   var config = new HttpSelfHostConfiguration(baseAddress);
   config.Routes.MapHttpRoute(
      name: "DefaultApi",
      routeTemplate: "api/{controller}/{id}",
      defaults: new
      {
         id = RouteParameter.Optional
      });

   var server = new HttpSelfHostServer(config);
   server.OpenAsync().Wait();
   Console.WriteLine("The server is running...");
}

When you have installed ASP.NET MVC4 Beta you will get the following error

Could not load type 'System.Web.Http.RouteParameter' from assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

Because the signed assembly has the same version it will always load the one that reside in the GAC. There are breaking changes in the new version and it clearly doesn't load the latest 'System.Web.Http' assembly within the solution! This can be seen and monitored by using Fuslogvw.

To resolve this problem we can use DEVPATH. It's an environment variable that you can set to a folder (typically you're output folder). The runtime will use the DEVPATH folder for probing before looking into the GAC! After setting the DEVPATH environment variable (I had to restart my Visual Studio to take effect) you have to add the following in the config file and after that everything worked fine.

<?xml version="1.0"?>
<configuration>
  <runtime>
    <developmentMode developerInstallation="true"/>
  </runtime>
</configuration>