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
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?)
Submit form swallowed brackets. The GetService has the template parameter:
<Microsoft.VisualStudio.Services.Location.Server.ILocationService>
Marc,
For TFS 2017, it seems the APIs have changed. Try using GetSelfReferenceUrl instead.
–Neno