TFS & Visual Studio ALM – by Neno Loje

(formerly Team System, VSTS)

Solved: The type ‘Microsoft.TeamFoundation.Framework.Client.ILocationService’ cannot be used as type parameter…

February 22nd, 2016 · 2 Comments · TFS Extensibility

The Problem

You are receiving one of the following compiler errors:

The type ‘Microsoft.TeamFoundation.Framework.Client.ILocationService’ cannot be used as type parameter ‘TService’ in the generic type or method ‘VssRequestContextExtensions.GetService<TService>(IVssRequestContext)’. There is no implicit reference conversion from ‘Microsoft.TeamFoundation.Framework.Client.ILocationService’ to ‘Microsoft.TeamFoundation.Framework.Server.IVssFrameworkService’.

‘ILocationService’ does not contain a definition for ‘GetSelfReferenceUri’ and no extension method ‘GetSelfReferenceUri’ accepting a first argument of type ‘ILocationService’ could be found (are you missing a using directive or an assembly reference?)

‘ILocationService’ does not contain a definition for ‘GetServerAccessMapping’ and no extension method ‘GetServerAccessMapping’ accepting a first argument of type ‘ILocationService’ could be found (are you missing a using directive or an assembly reference?)

The Solution

ILocationService exists in two namespaces. Make sure you use Microsoft.VisualStudio.Services.Location.Server.ILocationService (from Microsoft.TeamFoundation.Framework.Server.dll).

–Neno

Tags:

2 Comments so far ↓

  • Marc

    Using ILocationService with the explicit namespace and still getting the same compiler errors:

    Microsoft.VisualStudio.Services.Location.Server.ILocationService locationService = requestContext.GetService();

    var tfsUri = locationService.GetSelfReferenceUri(requestContext, locationService.GetDefaultAccessMapping(requestContext));

    ==>

    error CS1061: ‘ILocationService’ does not contain a definition for ‘GetSelfReferenceUri’ and no extension method ‘GetSelfReferenceUri’ accepting a first argument of type ‘ILocationService’ could be found (are you missing a using directive or an assembly reference?)

    • Marc

      Submit form swallowed brackets. The GetService has the template parameter:

      <Microsoft.VisualStudio.Services.Location.Server.ILocationService>

Leave a Comment