VSProject2.Project Property


Gets the generic Project object associated with the Visual Basic or Visual C# project.

 property EnvDTE::Project ^ Project { EnvDTE::Project ^ get(); };
 property EnvDTE::Project ^ Project { EnvDTE::Project ^ get(); };
[get: System.Runtime.InteropServices.DispId(4)]
public EnvDTE.Project Project { get; }
member this.Project : EnvDTE.Project
Public ReadOnly Property Project As Project

Property Value

A Project object.




To run this example as an add-in, see How to: Compile and Run the Automation Object Model Code Examples. Open a Visual Basic or Visual C# project before running this example.

[Visual Basic]

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)  
End Sub  
Sub VSProjectSavedExample(ByVal dte As DTE2)  
    Dim aProject As Project  
    Dim aVSProject As VSProject2  
    aProject = applicationObject.Solution.Projects.Item(1)  
    aVSProject = CType(applicationObject.Solution.Projects.Item(1)._  
    Object, VSProject2)  
End Sub  
' Displays whether project has unsaved changes.  
Sub IsProjectSaved(ByVal aVSProject As VSProject2)  
    Dim theProject As EnvDTE.Project  
    theProject = aVSProject.Project  
    If (theProject.Saved) Then  
        MsgBox(theProject.Name & " is saved.")  
        MsgBox(theProject.Name & " is not saved.")  
    End If  
End Sub  


using System.Windows.Forms;  
using VSLangProj;  
using VSLangProj2;  
using VSLangProj80;  
public void OnConnection(object application, ext_ConnectMode  
 connectMode, object addInInst, ref Array custom)  
    applicationObject = (DTE2)application;  
    addInInstance = (AddIn)addInInst;  
public void VSProjectSavedExample( DTE2 dte )   
    Project aProject = null;   
    VSProject aVSProject = null;   
    aProject = applicationObject.Solution.Projects.Item( 1 );   
    aVSProject = ( ( VSProject )( applicationObject.Solution.Projects.  
Item( 1 ).Object ) );   
    IsProjectSaved( aVSProject );   
//  Displays whether project has unsaved changes.  
public void IsProjectSaved( VSProject aVSProject )   
    EnvDTE.Project theProject = null;   
    theProject = aVSProject.Project;   
    if ( ( theProject.Saved ) )   
        MessageBox.Show( theProject.Name + " is saved.");   
        MessageBox.Show( theProject.Name + " is not saved.");   


The VSProject2 object is a property of a generic Project object. The Project property provides access to the general extensibility Project object.

Applies to