Skip to content

Instantly share code, notes, and snippets.

@joergbattermann
Created February 1, 2012 14:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joergbattermann/1717049 to your computer and use it in GitHub Desktop.
Save joergbattermann/1717049 to your computer and use it in GitHub Desktop.
Open TFS WorkItem within a running Visual Studio instance
private static DocumentService _workItemDocumentService;
private static void OpenWorkItem(TeamFoundationServer tfsServer, int workItemId)
{
if(_workItemDocumentService == null)
_workItemDocumentService = (DocumentService)DTE2.DTE.GetObject("Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.DocumentService");
// you can also use _workItemDocumentService = (DocumentService)Package.GetGlobalService(typeof(DocumentService));
IWorkItemDocument workItemDocument = workItemDocumentService.GetWorkItem(activeTFS, workItemId, this);
try
{
if (!workItemDocument.IsLoaded)
workItemDocument.Load();
workItemDocumentService.ShowWorkItem(workItemDocument);
}
finally
{
workItemDocument.Release(this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment