locked
WorkItemStore in IWorkItemControl RRS feed

  • Question

  • I am developing a custom work item control using the IWorkItemControl interface. The interface provides me with an IServiceProvider. However, when I try the retrieve the WorkItemStore, it always returns null:

    WorkItemStore wit = (WorkItemStore)_serviceProvider.GetService(typeof(WorkItemStore));
    

    How do I get an instance of the WorkItemStore? I can't seem to get a reference to the active TeamFoundationServer connection either (nor the Visual Studio DTE).

    Thursday, July 21, 2011 3:20 PM

Answers

  • I have figured out a workaround. The IServiceProvider instance is in fact a WitPackage (although it seems to be a private, hidden class). Using reflection I managed to find that it had a method called "GetActiveTfsTeamProjectCollection" which returns a TfsTeamProjectCollection. Using that, I was then able to call GetService<WorkItemStore>() giving me an instance of the WorkItemStore!

    @Microsoft, why not make the WitPackage class accessible?

    • Marked as answer by Yi Feng Li Monday, August 1, 2011 12:52 PM
    Friday, July 22, 2011 7:34 AM

All replies

  • I have figured out a workaround. The IServiceProvider instance is in fact a WitPackage (although it seems to be a private, hidden class). Using reflection I managed to find that it had a method called "GetActiveTfsTeamProjectCollection" which returns a TfsTeamProjectCollection. Using that, I was then able to call GetService<WorkItemStore>() giving me an instance of the WorkItemStore!

    @Microsoft, why not make the WitPackage class accessible?

    • Marked as answer by Yi Feng Li Monday, August 1, 2011 12:52 PM
    Friday, July 22, 2011 7:34 AM
  • Hi,

    I'm glad to know you have found a workaround for this issue.

    For your question about WitPackage, since it is a TFS related API, I suggest you repost this question to TFS forums at http://social.msdn.microsoft.com/Forums/en-US/category/vsts for better assist.

    Regards,

    Yi 


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Tuesday, July 26, 2011 8:41 AM