Currently when I call GetWorkspace
I get ItemNotMappedException
exception, but when I iterate over workspaces manually I can get my code working. This is so bizarre that I am wondering if I should call some refresh or something before I call GetWorkspace
?
Here is my code:
Workspace active = null;
using (var tfs = new TfsTeamProjectCollection(uri))
{
tfs.EnsureAuthenticated();
VersionControlServer vcs = tfs.GetService<VersionControlServer>();
// displaying info and manually finding desired workspace
foreach (var ws in vcs.QueryWorkspaces(null, vcs.AuthorizedUser, Environment.MachineName))
{
Console.WriteLine(ws.Name);
foreach (var f in ws.Folders)
{
Console.WriteLine($" {f.LocalItem}");
if (f.LocalItem == map_path)
active = ws;
}
}
// at this point workspace is found and I can work with it
// but this will crash
Workspace workspace = vcs.GetWorkspace(map_path);
}
I use VS2015 and the library for TFS is fetched from NuGet repo. It is "Microsoft.TeamFoundationServer.ExtendedClient" version "15.112.1".