.net 获取元素DTE\u applicationObject Visual Studio加载项的BaseName

.net 获取元素DTE\u applicationObject Visual Studio加载项的BaseName,.net,visual-studio,add-in,.net,Visual Studio,Add In,我正在尝试使用VisualStudio加载项获取元素的定义,但无法访问 选定行上元素的签名 我有如下代码块: sub Test(){ Dim TestVariable As New TestClass TestVariable.Execute() } 我选择了一行 TestVariable.Execute() 但此操作位于外接程序中: _applicationObject.ActiveDocument.ProjectItem.FileCodeModel. _ CodeElementF

我正在尝试使用VisualStudio加载项获取元素的定义,但无法访问 选定行上元素的签名

我有如下代码块:

sub Test(){
  Dim TestVariable As New TestClass
  TestVariable.Execute()
}
我选择了一行

TestVariable.Execute()
但此操作位于外接程序中:

_applicationObject.ActiveDocument.ProjectItem.FileCodeModel. _
CodeElementFromPoint(sel.AnchorPoint, vsCMElement.vsCMElementFunction)
返回Test(),它是最上面的元素,但我需要最里面的元素

我试图将“vsCMElementFunction”属性更改为属性等。 但他们都一无所获


有人知道另一种方法吗?

我找到了解决问题的方法,我想与大家分享

'When Your Cursor On The Element, Call Your Add-In
'In Exec() Function You Can Follow These Steps:

'Open Object Browser And Copy The Signature

_applicationObject.ExecuteCommand("Edit.GoToDefinition")
_applicationObject.ExecuteCommand("Edit.Copy")

'To Close The Object Browser

Dim win As EnvDTE.Window
win = DirectCast(_applicationObject.ActiveWindow, EnvDTE.Window)

'And ta ta, Full Signature Of The Element

basename = My.Computer.Clipboard.GetText()

'And Here We Get The Base Name

Dim tobjbasearr As String() = basename.Split(CChar("."))
Dim tobjbase As String = tobjbasearr(0)