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 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关详细信息,请参阅通过部分受信任的代码使用库。