Rory Primrose

Learn from my mistakes, you don't have time to make them yourself

View project on GitHub

How much do I love the yield statement?

Quite simply, a lot. The yield statement seems to be such a simple part of C# yet it can provide such amazing power (being delayed enumeration). Outside of that power however, it can provide beautiful simplicity.

Take the following abstract class for example:

Read More

Configuring a TFS 2010 build agent to compile SharePoint 2010 projects

I’ve been doing several TFS consulting gigs over the last couple of years. The one thing that keeps popping up is the requirement to build several types of platforms using TeamBuild/TFSBuild. My preference is to isolate build agents and their customisations. This means for example that I have a mix of build agents like the following:

  • Standard (full VS install + any common additions - WiX for example)
  • SharePoint
  • BizTalk

Tagging the build agents and configuring the build definitions for those tags then allows the build to be directed to the correct build agent.

Read More

Integration testing with Azure development storage

I’ve been working on some classes that write data to Azure table storage. These classes of course need to be tested. Unfortunately the development fabric only spins up when you F5 an Azure project. This is a little problematic when the execution is from a unit test framework.

Some quick searching brought up this post which provides 99% of the answer. The only hiccup with this solution is that it is targeting the 1.0 version of the Azure SDK. I have updated this code to work with the 1.6 version of the SDK.

Read More

Performance Testing a Load Test

Running a load test in Visual Studio is a great way to put your code under stress. The problem is that once you have identified that there is a potential performance issue, how do you then narrow it down to particular methods in your code base. Using a Performance Session is great for this.

The problem is that Visual Studio does not provide out of the box support for running a performance session against a load test. There is a reasonably easy workaround though. Any other profiling tool will also work using the same technique. The trick is to get the performance session to manually profile mstest.exe as it runs the load test.

Read More

Movember - Please donate

It’s not often that I post something personal on this blog. Movember is an important cause so I’ll make an exception.

It’s Movember and time to focus on men’s health. To show my commitment, I’m donating my face to the cause by growing a moustache for the entire month of November, and need your support. My Mo will spark conversations, and no doubt generate some laughs; all in the name of raising vital awareness and funds for prostate cancer and male depression.

Why am I so passionate about men’s health?

  • 1 in 9 men will be diagnosed with prostate cancer in their lifetime
  • This year 20,000 new cases of the disease will be diagnosed
  • 1 in 8 men will experience depression in their lifetime

I’m asking you to support my Movember campaign by making a donation by either:

  • Donating online at:
  • Writing a cheque payable to ‘Movember’, referencing my Registration ID: 2443216 and mailing it to: Movember, PO Box 60, East Melbourne, VIC, 8002, Australia

If you’d like to find out more about the type of work you’d be helping to fund by supporting Movember, take a look at the Programs We Fund section on the Movember website:

Thank you in advance for supporting my efforts to change the face of men’s health.

Rory Primrose

Read More

AssemblyVersion regular expression

It seems that I keep having to come up with a regular expression that validates and parses a version string. I often use this for customising TFS build workflows for extracting and using application version information.

The AssemblyVersionAttribute appears to have the following rules:

  • Major version is required
  • Minor version is optional and will default to 0 if not specified
  • Minor version cannot be *
  • Build and Revision versions are optional and may be *
  • Revision number cannot be specified if the build number is *

The following is the regular expression that covers all these rules.

Read More

Getting the X509Certificate from a remote HTTPS resource

How do you download the X509Certificate that secures a HTTPS channel? I want to do this for two reasons.

  1. Identify the reason for a trust failure
  2. Identify if the certificate is about to expire

I ran all sorts of searches on the net about how to get the certificate of the remote host. Unfortunately the results were not quite what I was after.

The answer is that the certificate is provided by HttpWebRequest.ServicePoint.Certificate. The tricky bit is that the certificate is only available once a response has come back from the host. This makes sense, but it is misleading that the certificate based on the response is stored against the original request object. It is also a little confusing that the certificate is available on the request when the attempt to get the response threw an exception (a failed certificate trust for example).

Read More

Neovolve.Toolkit 1.1 Released

It has taken a while, but I have been able to push out a new release of my Neovolve.Toolkit. The major focus of this release has been in the custom activity support for WF4. This version is now distributed via an MSI.

This release of the Neovolve.Toolkit package targets .Net 4 and contains support for WF4 as well as fixes to the existing code base. It supports the Client Profile version of the .Net 4 framework on many of the assemblies for a smaller footprint. The package now supports a VSIX package for Visual Studio integration of the toolbox for WF4 activities and the Add Reference dialog (see here for the details).
The following pages describe what each assembly in the package contains.

The package is available via Codeplex and the Visual Studio Gallery.

Read More

Dealing with ExecutionEngineException, code contracts and WF

I recently battled the scary ExecutionEngineException. It’s scary because the exception itself does not provide any information about what has gone wrong and why. Figuring out why the exception is being thrown can get a little tricky.

In my scenario, Visual Studio was crashing when trying to display a WF designer. After attaching another Visual Studio instance to debug the crash, I found that the exception being thrown in the designer was ExecutionEngineException. The place it was being thrown was in an evaluation of a Code Contract (Requires<ArgumentNullException>). I quickly realised that I had added some code contracts into my WF design assembly but not enabled the code contract rewriter for compiling the assembly. Rather than throwing an ArgumentNullException for a given condition, the contract was not correctly written into the assembly and the framework threw ExecutionEngineException instead.

The ExecutionEngineException appears to be a fairly low level exception. Unfortunately its use in Code Contracts is confusing because of the lack of information about what is going wrong and how the developer should fix it.

Read More