현재 GetWorkspace
을 호출하면 ItemNotMappedException
예외가 발생하지만 수동으로 작업 영역을 반복 할 때 코드가 작동 할 수 있습니다. 이것은 이상한 일로 GetWorkspace
으로 전화하기 전에 새로 고침이나 다른 것을해야하는지 궁금합니다.TFS에서 GetWorkspace를 올바르게 호출하는 방법은 무엇입니까?
여기 내 코드입니다 :
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);
}
내가 VS2015를 사용하고 TFS의 라이브러리는 NuGet의의 repo에서 가져온 것입니다. "Microsoft.TeamFoundationServer.ExtendedClient"버전 "15.112.1"입니다.
이 다음의 중복 :
이 비슷한 질문을 살펴 유무 :작업 공간 정보 캐시를 업데이트 강제로 코드에서
Workstation.EnsureUpdateWorkspaceInfoCache
에 전화를 시도? https://stackoverflow.com/questions/29976960/issue-with-tfs-versioncontrolserver-getworkspace-throwing-itemnotmappedexception –@BernardVanderBeken을 참조하십시오. 고맙습니다.하지만, 잠시 후에 내 질문을 업데이트하겠습니다. – astrowalker