ProjectItems.ContainingProject 屬性
取得裝載一或多個專案項目的專案。
命名空間: EnvDTE
組件: EnvDTE (在 EnvDTE.dll 中)
語法
'宣告
ReadOnly Property ContainingProject As Project
Project ContainingProject { get; }
property Project^ ContainingProject {
Project^ get ();
}
abstract ContainingProject : Project with get
function get ContainingProject () : Project
屬性值
類型:EnvDTE.Project
Project 物件。
範例
Sub ContainingProjectExample(ByVal dte As DTE2)
' Before running this example, open a code document from a project.
Try
' Create a new namespace.
Dim projItem As ProjectItem = dte.ActiveDocument.ProjectItem
Dim cm As CodeModel = projItem.ContainingProject.CodeModel
cm.AddNamespace("TestNamespace", projItem.Name)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
public void ContainingProjectExample(DTE2 dte)
{
// Before running this example, open a code document from
// a project.
try
{
// Create a new namespace.
ProjectItem projItem = dte.ActiveDocument.ProjectItem;
CodeModel cm = projItem.ContainingProject.CodeModel;
cm.AddNamespace("TestNamespace", projItem.Name, -1);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。