Search code examples
tfstfs-sdk

TFS API TestManagementService always returns null


I'm trying to get test plans by using TFS API.

TfsTeamProjectCollection tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://xxxxxxx:8080/tfs/DefaultCollection"));

var service = (ITestManagementService)tfs.GetService(typeof(ITestManagementService));

The variable "service" always returns null.

Do you have any idea, why?


Solution

  • Perhaps you're linking against different versions of reference assemblies, mixing different versions of Visual Studio assemblies? Example:

    • Microsoft.TeamFoundation.Client v11.0 (VS 2012)
    • Microsoft.TeamFoundation.TestManagement.Client v12.0 (VS 2013)

    I had the same problem of GetService<ITestManagementService>() always returning null, even when GetService<VersionControlServer>() would return good (non-null) value.

    The solution posted in MSDN - VersionControlServer always returns null worked for me: I had references to some v11.0 (VS2012) and v12.0 (VS2013) assemblies. Changing all references to v11.0 fixed it for me.