Solution2 Interface
Collapse the table of content
Expand the table of content
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. ArchiveDisclaimer

Solution2 Interface 

Represents all projects and solution-wide properties in the integrated development environment (IDE).

Namespace: EnvDTE80
Assembly: EnvDTE80 (in envdte80.dll)

public interface Solution2 : _Solution
/** @attribute GuidAttribute("FA238614-FBB1-4314-A7F7-49AE8BB6C6BA") */ 
public interface Solution2 extends _Solution
public interface Solution2 extends _Solution

The Solution object is a collection of all 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).

For information on how to run this add-in code, see How to: Compile and Run the Automation Object Model Code Examples.

using System.Windows.Forms;
public void OnConnection(object application,
 Extensibility.ext_ConnectMode connectMode, object addInInst,
 ref System.Array custom)
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    // Pass the applicationObject member variable to the code example.

public void SolutionExample(DTE2 dte)
    // This function creates a solution and adds a Visual C# Console
    // project to it.
        Solution2 soln = (Solution2)_applicationObject.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);
© 2015 Microsoft