How to acquire DTE object instance in a VS package project?

后端 未结 2 557
终归单人心
终归单人心 2020-12-18 13:09

How can I get DTE instance in a VS package project? It\'s straigtforward in addin project since application is being passed as an argument to onConnection

相关标签:
2条回答
  • 2020-12-18 14:00

    You can get a null instance getting the SDTE service if the shell is not fully initialized. See how to handle that in this code sample:

    HOWTO: Get the EnvDTE.DTE instance from a package

    0 讨论(0)
  • 2020-12-18 14:05

    From your main Package class:

    EnvDTE80.DTE2 dte = this.GetService(typeof(Microsoft.VisualStudio.Shell.Interop.SDTE)) as EnvDTE80.DTE2;
    
    0 讨论(0)
提交回复
热议问题