Partilhar via


Solution4.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)  
    ‘ Display the number of projects in a solution.  
    ' Open a solution in Visual Studio before running this example.  
    Try  
        Dim soln As Solution4 = CType(_applicationObject.Solution, _  
        Solution4)  
        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)  
{  
    // Display the number of projects in a solution.   
    // Open a solution in Visual Studio before running this example.  
    try  
    {  
        Solution4 soln = (Solution4)_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