Solution4 Interface


Represents all projects and solution-wide properties in the integrated development environment (IDE). Supersedes Solution, Solution2, and Solution3.

Namespace:   EnvDTE100
Assembly:  EnvDTE100 (in EnvDTE100.dll)

public interface Solution4 : Solution3


Gets an AddIns collection, which contains all currently available add-ins associated with the solution.

Add-ins are deprecated. For more information, see FAQ: Converting Add-ins to VSPackage Extensions.


Gets a value indicating the number of projects in the solution.


Gets the top-level extensibility object.


Gets the requested Extender object if it is available for this object.


Gets the Extender category ID (CATID) for the object.


Gets a list of available Extenders for the object.


This API supports the product infrastructure and is not intended to be used directly from your code. Gets the file name.


Gets the full path and name of the object's file.


Gets the Globals object that contains any variable values that may be saved in the solution (.sln) file, the project file, or the user's profile data.


This API supports the product infrastructure and is not intended to be used directly from your code. Determines whether the solution is dirty (modified but not saved).


Gets whether a solution is open.


Gets the immediate parent object of a Solution2 object.


Gets a collection of the projects currently in the solution.


Gets a collection of all properties that pertain to the Solution2 object.


Gets or sets a value indicating whether a solution has not been modified since last being saved or opened.


Gets the SolutionBuild object for the solution, which represents the root of the build automation model at the solution level.


Superseded by GetProjectTemplate.

System_CAPS_pubmethodAddFromFile(String, Boolean)

Adds a project to the solution that is based on a project file already stored in the system.

System_CAPS_pubmethodAddFromTemplate(String, String, String, Boolean)

Copies an existing project file, and any items or subdirectories it contains, to the specified location and adds it to the solution.

System_CAPS_pubmethodAddFromTemplateEx(String, String, String, String, Boolean, UInt32)

Copies an existing project file, and any items or subdirectories it contains, to the specified location and adds it to the solution.


Adds a solution folder to a ProjectItems collection.


Closes the current solution.

System_CAPS_pubmethodCreate(String, String)

Creates an empty solution in the specified directory with the specified name.


Locates an item in a project.


Returns an enumeration for items in a collection.

System_CAPS_pubmethodGetProjectItemTemplate(String, String)

Returns a path to the indicated project item template.

System_CAPS_pubmethodGetProjectItemTemplates(String, String)

Returns a collection of project item templates for the specified project.

System_CAPS_pubmethodGetProjectTemplate(String, String)

Returns a path to the specified project template.

If a template has a RequiredFrameworkVersion element higher than 4.0, you should provide the version in the call so that the search for the template will find a match. For example, instead of calling GetProjectTemplate("Extensibility\\1033\\", "CSharp"); call GetProjectTemplate("Extensibility\\1033\\|FrameworkVersion=4.5", "CSharp");.


Returns an indexed member of a Projects collection.


Opens a specified solution.


Superseded by GetProjectItemTemplate.


Removes the specified project from the solution.


Saves the solution.

The Solution4 object is a collection of all projects in the current instance of the IDE and all solution-wide properties, such as build configurations. The Solution4 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 Solution4.Item(EnvDTE.Constants.vsProjectKindMisc) or Solution4.Item(EnvDTE.Constants.vsProjectKindSolutionItems).

using System.Windows.Forms;
public void Solution4Example(DTE2 dte)
    // This function creates a solution and adds a Visual C# Console
    // project to it.
        Solution4 soln = (Solution4)dte.Solution;
        String csTemplatePath;
        // The file path must exist on your computer.
        // Replace <file path> below with an actual path.
        String csPrjPath = "<file path>";
        "<file path>MessageBox.Show("Starting...");
        "<file path>"<file path>csTemplatePath = 
        soln.GetProjectTemplate("", "CSharp");
        // Create a new C# Console project using the template obtained 
        // above.
        soln.AddFromTemplate(csTemplatePath, csPrjPath,
          "New CSharp Console Project", false);
    catch(SystemException ex)
        MessageBox.Show("ERROR: " + ex);
Return to top