ProjectItem.ContainingProject Property
Gets the project hosting the ProjectItem.
Namespace: EnvDTE
Assembly: EnvDTE (in EnvDTE.dll)
Syntax
'Declaration
ReadOnly Property ContainingProject As Project
'Usage
Dim instance As ProjectItem
Dim value As Project
value = instance.ContainingProject
Project ContainingProject { get; }
property Project^ ContainingProject {
Project^ get ();
}
function get ContainingProject () : Project
Property Value
Type: EnvDTE.Project
A Project object.
Examples
[Visual Basic]
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 Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
Other Resources
How to: Compile and Run the Automation Object Model Code Examples