Search code examples
c#-4.0visual-studio-2015vsixtfs-2015

Get the running instance of VersionControlServer(tfs 2015) from Visual Studio 2015 to bind a GettingEventHandler to it


I want to scan all XML-Files that have been checked out of the Server.

        Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt project =
        dte.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") as
            Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt.Project;

I tried this. But i get a NullPointerException.

I'm looking for something thats triggers an event or something. On Serverside there is the ISubscriber interface.

The dte object isnt working either cause it hast no event trigger.

----edit---

There is a "GettingEventHandler" in Tfs.client Package. I can bind things together but i need the VersionControlServer Instance running in Visual Studio 2015


Solution

  • I read over that all Events from TFS are crossinstance. I just started a new instance and attached my eventhandler to it. It works great.

            tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(serveradressename));
            versionControl = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
            versionControl.Getting += new GettingEventHandler(ScanAllNewDocs);