Solution2.DTE 屬性
取得最上層的擴充性物件。
命名空間: EnvDTE80
組件: EnvDTE80 (在 EnvDTE80.dll 中)
語法
'宣告
ReadOnly Property DTE As DTE
DTE DTE { get; }
property DTE^ DTE {
DTE^ get ();
}
abstract DTE : DTE
function get DTE () : DTE
屬性值
型別:EnvDTE.DTE
DTE 物件。
備註
在 Visual Studio 中,DTE 物件是 Automation 模型的根物件,Automation 物件在其他物件模型中經常稱為「應用程式」。
範例
如需如何執行增益集程式碼的詳細資訊,請參閱 HOW TO:編譯和執行 Automation 物件模型程式碼範例。
下列範例會在開啟方案中尋找並顯示使用中視窗的標題。
Public Sub OnConnection(ByVal application As Object, _
ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
ByRef custom As Array) Implements IDTExtensibility2.OnConnection
_applicationObject = CType(application, DTE2)
_addInInstance = CType(addInInst, AddIn)
SolutionDTEExample(_applicationObject)
End Sub
Sub SolutionDTEExample(ByVal dte As DTE2)
' This add-in displays the caption of the active window,
' obtained through the DTE object. Open a solution in
' Visual Studio before running this example.
Try
Dim soln As Solution2 = CType(_applicationObject.Solution, _
Solution2)
MsgBox _
("The caption of the active window, obtained through the DTE object, is: " & _
vbCr & soln.DTE.ActiveWindow.Caption)
Catch ex As System.Exception
MsgBox(ex.ToString)
End Try
End Sub
//you will need to add this reference to your project as well
using System.Windows.Forms;
public void OnConnection(object application,
Extensibility.ext_ConnectMode connectMode, object addInInst,
ref System.Array custom)
{
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
// Pass the applicationObject member variable to the code example.
SolutionCount((DTE2)_applicationObject);
}
public void SolutionCount(DTE2 dte)
{
// This add-in displays the caption of the active window,
// obtained through the DTE object. Open a solution in
// Visual Studio before running this example.
Try
{
Solution2 soln = (Solution2)_applicationObject.Solution;
MessageBox.Show
("The caption of the active window, obtained through the DTE object, is: "
+ soln.DTE.ActiveWindow.Caption);
}
catch(SystemException ex)
{
MessageBox.Show("ERROR: " + ex);
}
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。