Solution2.Projects Property

Definition

Gets a collection of the projects currently in the solution.

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

Property Value

A Projects collection.

Implements

Attributes

Examples

Sub ProjectsExample(ByVal dte As DTE2)  
    ' Displays the number of projectsin a solution.  
    ' Open a solution in Visual Studio before running this example.  
    Try  
        Dim soln As Solution2 = CType(_applicationObject.Solution, _  
        Solution2)  
        Dim solnName As String = _  
        System.IO.Path.GetFileNameWithoutExtension(soln.FullName)  
        MsgBox("Solution " & solnName & _  
        " has " & soln.Projects.Count.ToString() & " projects")  
    Catch ex As System.Exception  
        MsgBox(ex.ToString)  
    End Try  
End Sub  
using System.Windows.Forms;  
public void ProjectExample(DTE2 dte)  
{  
    // Displays the number of projects in a solution.   
    // Open a solution in Visual Studio before running this example.  
    try  
    {  
        Solution2 soln = (Solution2)_applicationObject.Solution;  
        string solnName =  
 System.IO.Path.GetFileNameWithoutExtension(soln.FullName);  
        MessageBox.Show("Solution " + solnName + "has "   
+ soln.Projects.Count.ToString() + " projects.");  
    }  
    catch(SystemException ex)  
    {  
        MessageBox.Show("ERROR: " + ex);  
    }  
}  

Applies to