Unable to get IBuildServer - always returning null

March 20, 2015

I recently had a very strange error while using the TFS API. The error was with the following code:

var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(URI));
var vcs = tfs.GetService<VersionControlServer>();
var buildServer = tfs.GetService<IBuildServer>();                

The problem being that `buildServer` was being set to null. I had the TFS server set-up locally, and there was a controller, an agent and a build configured.

I spent a good while trying to debug, what I thought was, an error with the code.

The Solution

Turns out the problem was with the reference:


The problem was that I was referencing the wrong version (trying to connect to TFS2013 but the build client version was Swapping it to version works fine.

It sounds like a silly mistake, but if you make it, it’s very difficult to spot.

Profile picture

A blog about one man's journey through code… and some pictures of the Peak District

© Paul Michaels 2024