Solution2.AddIns 屬性
取得 AddIns 集合,此集合包含目前所有與方案相關的可用增益集。
命名空間: EnvDTE80
組件: EnvDTE80 (在 EnvDTE80.dll 中)
語法
'宣告
ReadOnly Property AddIns As AddIns
AddIns AddIns { get; }
property AddIns^ AddIns {
AddIns^ get ();
}
abstract AddIns : AddIns with get
function get AddIns () : AddIns
屬性值
類型:AddIns
AddIns。
備註
AddIns 集合中只會顯示已登錄的增益集,而且在載入和卸載方案時,這些增益集也會跟著載入和卸載。
範例
如需如何執行增益集程式碼的詳細資訊,請參閱 如何:編譯和執行 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)
SolutionAddInsExample(_applicationObject)
End Sub
Sub SolutionAddInsExample(ByVal dte As DTE2)
' This add-in counts the add-ins in a solution.
' Open a solution in Visual Studio before running this
' example.
Try
Dim soln As Solution2 = CType(_applicationObject.Solution, _
Solution2)
' List the number of add-ins.
MsgBox("Number of add-ins in" & soln.FullName & " is: " _
& soln.AddIns.Count)
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.
SolutionAddInsExample((DTE2)_applicationObject);
}
public void SolutionAddInsExample(DTE2 dte)
{
// This add-in counts the add-ins in a solution.
// Open a solution in Visual Studio before running this
// example..
try{
Solution2 soln =(Solution2)_applicationObject.Solution;
// List the number of Add-ins.
MessageBox.Show("Number of add-ins in" + soln.FullName
+ " is: " + "\n" + soln.AddIns.Count);
}
catch(SystemException ex)
{
MessageBox.Show("ERROR: " + ex);
}
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。