Search code examples
c#visual-studiovspackagevs-extensibility

c# VS 2015 Package recently getting null by GetService and Dte(2).GetObject without changes in the code


I'm using the following properties in a VS (2015) Package:

    public DTE Dte
    {
        get
        {
            return GetService(typeof(DTE)) as DTE;
        }
    }

    public ITeamFoundationContextManager TeamExplorer
    {
        get
        {
            return GetService(typeof(ITeamFoundationContextManager)) as ITeamFoundationContextManager;
        }
    }

    public DocumentService DocService
    {
        get
        {
            return Dte.GetObject("Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.DocumentService")
            as DocumentService;
        }
    }

The first one (Dte) seems to work fine and returns a DTE object. The second (TeamExplorer) does always return null, just like the third property (DocService).

The problem is, that I (and no other) did not check-in any changes since the last release build. The last release build still works on installation, but if I rebuild it, there is the null-value issue.

The problem also appears on a co-workers machine. My Extensibility Tools version is: 1.10.183


Solution

  • I don't know why, but some mechanism in VS/TFS or myself changed the project's

    <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
    

    to 12.0 and changed the assemblies to the lower version (12.x). Everything worked, after I changed the project file(s) and swapped the assemblies with the 14.x versions.