ProjectItems.ContainingProject 属性

获取承载项目项或项的项目。

命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)

语法

声明
ReadOnly Property ContainingProject As Project
    Get
Project ContainingProject { get; }
property Project^ ContainingProject {
    Project^ get ();
}
abstract ContainingProject : Project
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 安全性

请参见

参考

ProjectItems 接口

EnvDTE 命名空间

其他资源

如何:编译和运行自动化对象模型代码示例