Search code examples
c#visual-studio-extensionsvsix

VersionControlExt.Explorer is NULL if I call from solution explorer but if I call from Source Control Explorer then It is giving me value


I am developing a plugin for viewing customized change set on button click in solution explorer.

I need VersionControlServer reference for that, but I am not getting the reference if I click button from Solution explorer, But If click the button from source control explorer then it is working. But I need to call it from solution explorer/ Team Explorer.

this.m_applicationObject = _applicationObject; this.versionControlExt = (VersionControlExt)this.m_applicationObject.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt"); this.versionControlServer = this.versionControlExt.Explorer.Workspace.VersionControlServer;


Solution

  • Instead I used the url of the tfs server to get the version control explorer.

    var projectCollectionUri = new Uri(TFS_COLLECTION);
                    var projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(projectCollectionUri, new Microsoft.VisualStudio.Services.Common.VssCredentials());
                    projectCollection.EnsureAuthenticated();
                    this.versionControlServer = projectCollection.GetService<VersionControlServer>();