执行 TFS 命令时出错
我在调用 Workspace.Merge
时遇到异常。我正在访问 VersionControlExt
来自 VisualStudio。下面的代码可以访问 Visual Studio TFS 资源管理器窗口对象(该对象在环境中处于活动状态并且用户已登录)。
VersionControlExt vce;
vce = _applicationObject.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") as VersionControlExt;
MergeCandidate[] candidates = version.GetMergeCandidates(source, dest, RecursionType.Full);
Workspace ws = vce.Explorer.Workspace;
foreach (MergeCandidate mc in candidates)
{
string comment = mc.Changeset.Comment;
ChangesetVersionSpec csvs = new ChangesetVersionSpec(mc.Changeset.ChangesetId);
// HERE NULL REFERENCE EXCEPTION IS THROWN
GetStatus gs = ws.Merge(source, dest, csvs, csvs, LockLevel.None, RecursionType.Full, MergeOptionsEx.None);
}
异常详细信息
目标站点:{System.String get_AuthorizedUser()}
StackTrace
在 Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer.get_AuthorizedUser()\r\n 在 Microsoft.TeamFoundation.VersionControl.Client.Workspace.get_DisplayName()\r\n 在 Microsoft.TeamFoundation.VersionControl.Client.Workspace.RequireLocal()\r\n 在 Microsoft.TeamFoundation.VersionControl.Client.Workspace.Merge(ItemSpec 源、字符串目标路径、版本规范 版本从,版本规范版本到, LockLevel lockLevel, MergeOptionsEx 合并选项,字符串[] propertyNameFilters)\r\n 位于 Microsoft.TeamFoundation.VersionControl.Client.Workspace.Merge(ItemSpec 源、字符串目标路径、版本规范 版本从,版本规范版本到, LockLevel lockLevel, MergeOptionsEx mergeOptions)\r\n at Microsoft.TeamFoundation.VersionControl.Client.Workspace.Merge(字符串 源路径,字符串目标路径, VersionSpec 版本来自、VersionSpec versionTo,LockLevel 锁级别, Recursion类型递归, MergeOptionsEx mergeOptions)\r\n
I have an exception when calling Workspace.Merge
. I am getting access to VersionControlExt
from VisualStudio. The code below gets access to Visual Studio TFS explorer window object (that is active in the environment and user is logged in).
VersionControlExt vce;
vce = _applicationObject.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") as VersionControlExt;
MergeCandidate[] candidates = version.GetMergeCandidates(source, dest, RecursionType.Full);
Workspace ws = vce.Explorer.Workspace;
foreach (MergeCandidate mc in candidates)
{
string comment = mc.Changeset.Comment;
ChangesetVersionSpec csvs = new ChangesetVersionSpec(mc.Changeset.ChangesetId);
// HERE NULL REFERENCE EXCEPTION IS THROWN
GetStatus gs = ws.Merge(source, dest, csvs, csvs, LockLevel.None, RecursionType.Full, MergeOptionsEx.None);
}
Exception Details
TargetSite: {System.String
get_AuthorizedUser()}
StackTrace
at
Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer.get_AuthorizedUser()\r\n
at
Microsoft.TeamFoundation.VersionControl.Client.Workspace.get_DisplayName()\r\n
at
Microsoft.TeamFoundation.VersionControl.Client.Workspace.RequireLocal()\r\n
at
Microsoft.TeamFoundation.VersionControl.Client.Workspace.Merge(ItemSpec
source, String targetPath, VersionSpec
versionFrom, VersionSpec versionTo,
LockLevel lockLevel, MergeOptionsEx
mergeOptions, String[]
propertyNameFilters)\r\n at
Microsoft.TeamFoundation.VersionControl.Client.Workspace.Merge(ItemSpec
source, String targetPath, VersionSpec
versionFrom, VersionSpec versionTo,
LockLevel lockLevel, MergeOptionsEx
mergeOptions)\r\n at
Microsoft.TeamFoundation.VersionControl.Client.Workspace.Merge(String
sourcePath, String targetPath,
VersionSpec versionFrom, VersionSpec
versionTo, LockLevel lockLevel,
RecursionType recursion,
MergeOptionsEx mergeOptions)\r\n
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
异常的类型和消息是什么?
本地的 Team Explorer 版本是什么? TFS 服务器是什么版本?
鉴于堆栈顶部的 get_AuthorizedUser ,我怀疑这是 TFS 客户端无法进行身份验证 - 首先检查当前目录是否位于映射工作区中以及当前用户是否已在 TFS 上获得授权。
What is the exception's Type and Message?
What version of Team Explorer locally? What version of TFS server?
Given
get_AuthorizedUser
at top of stack, I suspect this is the TFS client failing to authenticate—start by checking the current directory is in a mapped workspace and the current user is authorized on TFS.发现问题了。为了使用 TFS 功能,需要引用 Microsoft.TeamFoundation.VersionControl.Client.dll。我安装了 9.0 Studio 和 10.0 Studio。我在实际使用 9.0 studio 时引用了 10.0 的 dll。愚蠢的错误,但调试花了几个小时。
Found the problem. In order to use TFS functionality one needs to reference Microsoft.TeamFoundation.VersionControl.Client.dll. I have both 9.0 Studio and 10.0 Studio installed. I have referenced dlls from 10.0 while actually using 9.0 studio. Stupid mistake but it has taken hours to debug.