我们有一个 Visual Studio 2010 插件,主要处理 TFS 操作。当有人提交文件时,它会发送电子邮件给相应的人,并对一些其他本地 MSSQL 数据库进行一些更改,类似于检查和合并的情况。
长期以来,它与 TFS2005 配合工作良好,但最近我们将 tfs 从 2005 升级到了 2010,然后是 2013。
现在我们的插件不起作用了。简单地说,
下面是我的示例代码;
长期以来,它与 TFS2005 配合工作良好,但最近我们将 tfs 从 2005 升级到了 2010,然后是 2013。
现在我们的插件不起作用了。简单地说,
VersionControlServer
的事件没有触发。无论我如何尝试,Google 也找不到任何解决方案。我们认为 TFS2013 处理这些问题的方式不同,但这个插件对我们的工作至关重要,我们不想回滚到 TFS2005。下面是我的示例代码;
public void invoke()
{
// Get a reference to our Team Foundation Server.
var tpc = new TfsTeamProjectCollection(new Uri(_tfsURL));
// Get a reference to Version Control.
var versionControl = tpc.GetService<VersionControlServer>();
// Listen for the Source Control events.
versionControl.Getting += new GettingEventHandler(versionControl_Getting);
versionControl.BeforeCheckinPendingChange += new ProcessingChangeEventHandler(versionControl_BeforeCheckinPendingChange);
versionControl.NewPendingChange += new PendingChangeEventHandler(versionControl_NewPendingChange);
}
private void versionControl_NewPendingChange(object sender, PendingChangeEventArgs e)
{
//some logic here
}
private void versionControl_BeforeCheckinPendingChange(object sender, ProcessingChangeEventArgs e)
{
//some logic here
}
private void versionControl_Getting(object sender, GettingEventArgs e)
{
//some logic here
}
有什么可能导致这个问题吗?
提前感谢你的帮助。
更新:我已经找到了解决方案。我将上面的代码块改成了以下方式;
//+ _applicationObject.GetObject("Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt") {Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt} dynamic {Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt}
var tfsExt = (TeamFoundationServerExt)_applicationObject.GetObject("Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt");
//if ((tfsExt == null) || (tfsExt.ActiveProjectContext == null) || (tfsExt.ActiveProjectContext.DomainUri == null) || (tfsExt.ActiveProjectContext.ProjectUri == null)) { MessageBox.Show("Please Connect to TFS first and select a Team Project"); }
//else { MessageBox.Show("Connected to:" + tfsExt.ActiveProjectContext.ProjectName); }
var vsExt = _applicationObject.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") as VersionControlExt;
//vcs = vsExt.Explorer.Workspace.VersionControlServer;
vcs = vsExt.SolutionWorkspace.VersionControlServer;
vcs.OperationStarting += new OperationEventHandler(this.OperationHandler);
vcs.UndonePendingChange += new PendingChangeEventHandler(this.UndoChange);
vcs.Getting += new GettingEventHandler(this.GetHandler);
vcs.NewPendingChange += new PendingChangeEventHandler(this.NewPendingChange);
vcs.BeforeCheckinPendingChange += new ProcessingChangeEventHandler(this.BeforeCheckinPendingChange);
vcs.CommitCheckin += new CommitCheckinEventHandler(this.CommitCheckin);
vcs.Conflict += new ConflictEventHandler(this.Conflict);
vcs.Merging += new MergeEventHandler(this.Merging);
vcs.AfterWorkItemsUpdated += new AfterWorkItemsUpdatedEventHandler(this.AfterWorkItemsUpdated);
vcs.BeforeWorkItemsUpdate += new BeforeWorkItemsUpdateEventHandler(this.BeforeWorkItemsUpdate);
vcs.OperationFinished += new OperationEventHandler(this.OperationFinished);
vcs.UpdatedWorkspace += new WorkspaceEventHandler(this.UpdatedWorkspace);
vcs.WorkItemUpdated += new WorkItemUpdatedEventHandler(this.WorkItemUpdated);
通过使用Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt
,我们成功地解决了问题。感谢大家的支持。
更新2 不管我说多少次“谢谢”,都不足以表达Carlos Quintero所提供的帮助之深刻。再次感谢!