I like to checkout a file trough C# code, but I always get a TF14098 Acess Denied Exception. The TFS Administrator reassures, that I have checkout/edit permissions and in VisualStudio and with tf.exe I do not have any problems to checkout the file.
This is my current C# code:
const string tfsServer = @"http://MyServer:8080/tfs";
const string fileName = @"$/MyFile.xaml";
const string workspaceName = "MyWorkspace";
using (TfsTeamProjectCollection tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(tfsServer)))
{
if (tfs != null)
{
WorkspaceInfo workspaceInfo = Workstation.Current.GetLocalWorkspaceInfo(fileName);
if (null != workspaceInfo)
{
var vcs = tfs.GetService<VersionControlServer>();
Workspace workspace = workspaceInfo.GetWorkspace(tfs);
if(workspace == null){
workspace = vcs.GetWorkspace(workspaceName, vcs.AuthorizedUser);
}
vcs.NonFatalError += VersionControlOnNonFatalError;
vcs.Getting += OnGetting;
vcs.BeforeCheckinPendingChange += OnBeforeCheckinPendingChange;
vcs.NewPendingChange += OnNewPendingChange;
if (workspace != null)
{
workspace.PendEdit(fileName);
}
}
}
}
It results always with:
Non-fatal failure: TF14098: Access Denied: User Me needs PendChange permission(s) for $/MyFile.xaml.
After a lot of research for this error I tryed to check the permissions trough Dos-Box and I did the following commandline:
tf checkout $/MyFile.xaml
it results in a Checkout of the file without any problem! (If I am in the directory where the file resists)
Has anyone a Idea what the problem may be? What's the difference between my code (my Application written and executed with VisualStudio2012) and the commandline tf checkout?
Thanks for tips and hints! Patrik