1

I am using VS2015 and I try to check out files from a folder, that is included in a workspace: I have this mapping D:\tfs and I try to check out files from D:\tfs\MyProject\Subfolder1 I have added as references the Microsoft.TeamFoundation.VersionControl.Client and Microsoft.TeamFoundation.Client v12 and used to

   TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(tfsServerAddress));
   var versionControl = tfs.GetService<VersionControlServer>();
   var workspace = versionControl.TryGetWorkspace(pathToFolder);

But it does not work, I always get ItemNotMappedException.

This is an old code that used to work with VS2010 and I assume TFS2010. What is the newer approach for this?

Cœur
  • 32,421
  • 21
  • 173
  • 232
Angela
  • 349
  • 3
  • 14

1 Answers1

1

There is no way to make calling the API version independent.You need to use the same tfs client version to call the API.

Please try following below steps to fix the issue:

  1. Remove current reference Microsoft.TeamFoundation.VersionControl.Client and Microsoft.TeamFoundation.Client
  2. Install Microsoft Team Foundation Server Extended Client by running the following command in the Package Manager Console

PM > Install-Package Microsoft.TeamFoundationServer.ExtendedClient -Version 15.112.1

Then try it again.

You can also reference this similar thread to checkout the files: How can I programmatically check-out an item for edit in TFS?

Andy Li-MSFT
  • 24,802
  • 2
  • 22
  • 40