Search code examples
c#.nettfstfs-sdk

Can't retrieve TFS workspaces in c# with tfs API


I need to Get Latest Version of a TFS workspace that isn't mapped on my computer.

This is my code:

using (TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(
    new Uri("http://tfs:8080/tfs/project"), 
    new NetworkCredential("tfs", "pwd")))
{
    tfs.EnsureAuthenticated();

    VersionControlServer vcs = tfs.GetService<VersionControlServer>();

    Workspace w = vcs.GetWorkspace("VM-TFS", vcs.AuthorizedUser);

    // Implement w.Get(.....)
}

The problem is that on GetWorkspace() i received an exception: "TF14061: the workspace VM-TFS;DELTA\\tfs does not exist." (where the 'DELTA' before the username is our domain.)

I'm sure that the username is correct, that he is the owner of the workspace and the workspace name is correct too.

enter image description here

UPDATE

I found the problem. Initially I have imported the .dll directly with the intelliSense. In this way I think that Visual Studio reference the dlls that came with him. I tried to remove all them and to install with NuGet the 'Microsoft.TeamFoundationServer.ExtendedClient', and now it works!


Solution

  • I found the problem.

    Initially I have imported the .dll directly with the intelliSense. In this way I think that Visual Studio reference the dlls that came with him. I tried to remove all them and to install with NuGet the Microsoft.TeamFoundationServer.ExtendedClient, and now it works!