Solution4.AddIns 屬性
取得 AddIns 集合,包含目前所有與方案關聯的可用增益集。
命名空間: EnvDTE100
組件: EnvDTE100 (在 EnvDTE100.dll 中)
語法
'宣告
ReadOnly Property AddIns As AddIns
AddIns AddIns { get; }
property AddIns^ AddIns {
AddIns^ get ();
}
abstract AddIns : AddIns
function get AddIns () : AddIns
屬性值
型別:EnvDTE.AddIns
AddIns 集合。
備註
AddIns 集合中只會顯示已登錄的增益集,而且在載入和卸載方案時,這些增益集也會跟著載入和卸載。
範例
如需如何執行增益集程式碼的詳細資訊,請參閱 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)
Solution4Example(_applicationObject)
End Sub
Sub Solution4Example(ByVal dte As DTE2)
' This function creates a solution and adds a Visual C# Console
' project to it.
Try
Dim soln As Solution4 = CType(DTE.Solution, Solution4)
Dim csTemplatePath As String
' This path must exist on your computer.
' Replace <file path> below with an actual path.
Dim csPrjPath As String = "<file path>"
MsgBox("starting")
' Get the project template path for a C# console project.
csTemplatePath = CType(soln.GetProjectTemplate _
("ConsoleApplication.zip", "CSharp"), string)
' Create a new C# Console project using the template obtained
' above.
soln.AddFromTemplate(csTemplatePath, csPrjPath, _
"New CSharp Console Project", False)
MsgBox("done")
Catch ex As System.Exception
MsgBox(ex.ToString)
End Try
End Sub
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.
Solution4Example((DTE2)_applicationObject);
}
public void Solution4Example(DTE2 dte)
{
// This function creates a solution and adds a Visual C# Console
// project to it.
try{
Solution4 soln = (Solution4)_applicationObject.Solution;
String csTemplatePath;
// The file path must exist on your computer.
// Replace <file path> below with an actual path.
String csPrjPath = "<file path>";
"<file path>MessageBox.Show("Starting...");
"<file path>"<file path>csTemplatePath =
soln.GetProjectTemplate("ConsoleApplication.zip", "CSharp");
// Create a new C# Console project using the template obtained
// above.
soln.AddFromTemplate(csTemplatePath, csPrjPath,
"New CSharp Console Project", false);
MessageBox.Show("Done!");
}
catch(SystemException ex)
{
MessageBox.Show("ERROR: " + ex);
}
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。