问题
I have a small chunk of code that constantly fails when I try to get the workspace.
var tfs = new TfsTeamProjectCollection(new Uri("https://mytfs.com/projects"));
var versionControlServer = tfs.GetService<VersionControlServer>();
var workspace = versionControlServer.GetWorkspace(@"C:\MyProjects\ProjectA\BranchA");
I've verified that it's mapped in TFS (by, ya know, having worked on several branches of ProjectA over a couple years). I also specifically checked the mapping after I received the ItemNotMappedException and every level is mapped (C:\MyProjects was explicitly mapped, C:\MyProjects\ProjectA was explicitly mapped, and c:\MyProjects\ProjectA\BranchA is mapped).
No matter what variation I pass to versionControlServer.GetWorkspace(), it throws that error.
This is the extent of my TFS code. I have the TFS project collection correct (it failed a couple times until I found the exact url).
Just so you're aware, the only thing I want to be able to do is:
workspace.PendEdit(FilePath);
That is the only TFS command I need to execute at all. So if there is another way to do that, I'm open to it as well.
Hoping someone has an answer or suggestion!
回答1:
The answer was horrendous, however, the reference to Microsoft.TeamFoundation.VersionControl.Client by default was set to Copy Local: True, Specific Version: True.
Even though I only have one version of this dll on my system and it's being copied locally, when I set "Specific Version" to False, everything just magically worked.
I'm using VS 2013 and the dll is V12.0.0.0
来源:https://stackoverflow.com/questions/29976960/issue-with-tfs-versioncontrolserver-getworkspace-throwing-itemnotmappedexception