Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Solution Interface

Represents all projects and solution-wide properties in the integrated development environment (IDE). Use this object for functionality and refer to _Solution for documentation.

Namespace: EnvDTE
Assembly: EnvDTE (in envdte.dll)

public interface class Solution : _Solution
/** @attribute GuidAttribute("26F6CC4B-7A48-4E4D-8AF5-9E960232E05F") */ 
public interface Solution extends _Solution
public interface Solution extends _Solution

The Solution object is a collection of all the projects in the current instance of the IDE and all solution-wide properties such as build configurations. The Solution object contains a project element for every project, whether it is a wrapped project, a subproject, or a top-level project.

Reference this object by using DTE.Solution. To refer to virtual projects, such as MiscFiles or SolutionItems, use Solution.Item(EnvDTE.Constants.vsProjectKindMisc) or Solution.Item(EnvDTE.Constants.vsProjectKindSolutionItems).

This example works only in Visual Studio .NET 2003. For more information, see Migrating Code that Creates Projects by Using Templates.

Sub SolutionExample()
   ' This function creates a solution and adds a Visual Basic Console
   ' project to it. 
   Dim soln As Solution
   Dim proj As Project
   Dim msg As String

   ' Create a reference to the solution.
   soln = DTE.Solution

   ' Create a new solution.
   soln.Create("c:\temp2", "MyNewSolution")

   ' Create a new Visual Basic Console application project.
   ' Adjust the save path as needed.
   proj = soln.AddFromTemplate("D:\Program Files\Microsoft Visual Studio .NET\Vb7\VBWizards\ConsoleApplication\Templates\1033\ConsoleApplication.vbproj", "c:\temp2", "My New Project", True)
   ' Save the new solution and project.
   msg = "Created new solution: " & soln.FullName & vbCrLf
   msg = msg & "Created new project: " & proj.Name
End Sub

Community Additions

© 2015 Microsoft