Jake Ginnivan's blog

Web Api Problem - 404s for Everything

Scenario

So the scenario is that we are in the middle of migrating all our services into Azure, and there will be a time when our services will be running on premise and also in Azure.

We added this class to our project and added a reference to Microsoft.WindowsAzure.ServiceRuntime (from the GAC):

public class WebRole : RoleEntryPoint
{
    public override bool OnStart()
    {
        //Start code
        return base.OnStart();
    }
}

Our WebApi site starts 404'ing. There was also a heap of other work which was brought in at the same time, so tracking this down was rather hard.

Markpad Performance Push

If you haven’t seen Markpad, think Windows Live Writer, but for Jekyll, Pretzel, FunnelWeb blogs, and also editing normal markdown files.

MarkPad

While flying back from Oslo and NDC I spent probably 12+ hours of my ~20 hours of flying working on improving performance in MarkPad and cleaning up the codebase. This is documenting the most significant change.

DDD Melbourne Rest Talk

Over the weekend I presented at http://www.dddmelbourne.com/ on building RESTful web services.

I wanted to do it a bit different to the REST talks I had been to, and really try to cover how it all fits together, as well as the theory and covering the Richardson Maturity Model I put together a RESTful beer API, which I want to evolve over time as a cool example. My intention is to release WebApi.Hal as a NuGet package once it matures a little more and I figure out the API and conventions.

My slides are available here

All the sample code is available in the WebApi.Hal project on github (https://github.com/JakeGinnivan/WebApi.Hal) and I do accept pull requests. =)

The resource linker stuff is a bit clunky, but I think it is becoming quite a good example of a RESTful API. If you want to help out or have suggestions just fire me an email to jake at ginnivan dot net.

Azure and msshrtmi.dll

The Problem

A while back we received some Azure pull requests which added an Azure project and fixed all our SQL scripts so they were compatible with SQL Azure and that was pretty good, FunnelWeb would run in Azure.

The problem though is updates to the my.config required a full new deployment, so I wanted to support loading the configuration from the Role Environment config files instead when running in Azure.

So in our configuration settings class I put something like this:

public string Get(string name)
{
    return (RoleEnvironment.IsAvailable)
                ? RoleEnvironment.GetConfigurationSettingValue(name)
                : myConfigSettings.Get(name);
}

All good, local testing works beautifully. So I start with deploying to Azure Websites via git using the same script we use to deploy to AppHarbor. And boom:

---> System.TypeInitializationException: The type initializer for 'Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'msshrtmi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
   at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeEnvironment()
   at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.get_IsAvailable()

Getting Started With ApprovalTests Without Installing TortoiseSVN

I have just installed Windows 8 consumer preview on my dev machine, then all my API Approval tests started failing with this exception because I don’t have TortoiseMerge installed =(

System.ComponentModel.Win32Exception: System.ComponentModel.Win32Exception : The system cannot find the file specified
   at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start(String fileName, String arguments)
   at ApprovalTests.Reporters.DiffReporter.Launch(LaunchArgs launchArgs)
   at ApprovalTests.Reporters.DiffReporter.Report(String approved, String received)
   at ApprovalTests.Approvers.FileApprover.ReportFailure(IApprovalFailureReporter reporter)
   at ApprovalTests.Core.Approvals.Approve(IApprovalApprover approver, IApprovalFailureReporter reporter)
   at ApprovalTests.Approvals.Approve(IApprovalWriter writer, IApprovalNamer namer, IApprovalFailureReporter reporter)
   at Phoenix.Tests.ApiChanges.phoenix_has_no_public_api_changes() in C:\Users\Jake\_Code\Phoenix\src\net40\Phoenix.Tests\ApiChanges.cs:line 22
System.ComponentModel.Win32Exception: System.ComponentModel.Win32Exception : The system cannot find the file specified
   at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start(String fileName, String arguments)
   at ApprovalTests.Reporters.DiffReporter.Launch(LaunchArgs launchArgs)
   at ApprovalTests.Reporters.DiffReporter.Report(String approved, String received)
   at ApprovalTests.Approvers.FileApprover.ReportFailure(IApprovalFailureReporter reporter)
   at ApprovalTests.Core.Approvals.Approve(IApprovalApprover approver, IApprovalFailureReporter reporter)
   at ApprovalTests.Approvals.Approve(IApprovalWriter writer, IApprovalNamer namer, IApprovalFailureReporter reporter)

My issue is I don’t want to install TortoiseSVN just to get TortoiseMerge which ApiApprover uses by default.

So I created a Chocolatey package at http://chocolatey.org/packages/tortoisemerge which will download and add TortoiseMerge to your Path, then Approval Tests DiffReporter will just start working :)

Install Steps

1. Install Chocolatey

PS:> iex ((new-object net.webclient).DownloadString('http://bit.ly/psChocInstall'))

2. Install TortoiseMerge via Chocolatey

PS:> cinst TortoiseMerge

Done :)

ApiApprover

Recently I had an issue at work, we wanted to guarantee we had no breaking public API changes, and wanted to start adhering to semantic versioning.

The interesting thing about Semantic versioning is that often people accidentally break the semantic version. So I wrote a unit test which solves this problem

[Fact]
public void phoenix_has_no_public_api_changes()
{
    // arrange
    var phoenix = typeof(IPhoenixHost).Assembly;

    // act
    var publicApi = CodeGen.CreatePublicApiForAssembly(phoenix);

    // assert
    var reporter = new DiffReporter();
    Approvals.Approve(new ApprovalTextWriter(publicApi), new XUnitTestFrameworkNamer(), reporter);
}

WP7 MVC Debug and Tracing

WP7 Essentials Tracing

A new feature coming in the next release is a super easy to use Trace class to allow you to debug your app really easily.

My Sessions at TechEd 2011

DEV304 - Adding Value to Software Projects with VSTO (Wed, 11:30am)

This sessions will have something for everyone, if you have never used VSTO and are interested in it, I will be showing the value it has. If you have used it, and hated it, I will also be showing how to improve your experience and give you a way of approaching the problems and some nice ways to improve the default experience. Part of this is a quick intro to COM Interop, how it works and how to make sure you avoid problems with it. And finally, I will be showing a bit of VSTO contrib and how you can use IoC and other cool enhancements to the platform.

WPH305 - Multi-Tasking and Application Services (Fri, 8:15am)

In this session with Chris Walsh, we will be going through a whole lot of App services related features in Windows Phone Mango. We will cover things like Multi-Tasking, Background agents, Tiles, Notifications and Search extra’s. We have some cool demo’s and it will be a fun session.

Demos

I also have a few demo’s lined up - Unit Testing with WP7 (1:30pm Wednesday) - Windows Phone MVC Intro (2:00pm Wednesday)

  • Unit Testing with WP7 (1:00pm Wednesday)
  • Windows Phone MVC Intro (1:30pm Wednesday)

If you attend, feedback is always welcomed and please submit your evals, it helps us as speakers a lot.