Partager via


Solution2, interface

Mise à jour : novembre 2007

Représente tous les projets et les propriétés de la solution de l'environnement de développement intégré (IDE, Integrated Development Environment).

Espace de noms :  EnvDTE80
Assembly :  EnvDTE80 (dans EnvDTE80.dll)

Syntaxe

<GuidAttribute("FA238614-FBB1-4314-A7F7-49AE8BB6C6BA")> _
Public Interface Solution2 _
    Implements _Solution

Dim instance As Solution2
[GuidAttribute("FA238614-FBB1-4314-A7F7-49AE8BB6C6BA")]
public interface Solution2 : _Solution
[GuidAttribute(L"FA238614-FBB1-4314-A7F7-49AE8BB6C6BA")]
public interface class Solution2 : _Solution
public interface Solution2 extends _Solution

Notes

L'objet Solution est une collection de tous les projets de l'instance active de l'environnement de développement intégré (IDE) et de toutes les propriétés de la solution, telles que les configurations de génération. L'objet Solution contient un élément de projet pour chaque projet, qu'il s'agisse d'un projet retourné, d'un sous-projet ou d'un projet de niveau supérieur.

Référencez cet objet à l'aide de DTE.Solution. Pour référencer des projets virtuels, tels que MiscFiles ou SolutionItems, utilisez Solution.Item(EnvDTE.Constants.vsProjectKindMisc) ou Solution.Item(EnvDTE.Constants.vsProjectKindSolutionItems).

Exemples

Pour plus d'informations sur l'exécution de ce code de complément, consultez Comment : compiler et exécuter les exemples de code du modèle objet Automation.

Public Sub OnConnection(ByVal application As Object, _
 ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
 ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    _applicationObject = CType(application, DTE2)
    _addInInstance = CType(addInInst, AddIn)
    SolutionExample(_applicationObject)
End Sub

Sub SolutionExample(ByVal dte As DTE2)
    ' This function creates a solution and adds a Visual C# Console
    ' project to it.
    Try
        Dim soln As Solution2 = CType(DTE.Solution, Solution2)
        Dim csTemplatePath As String
        ' This path must exist on your computer.
        ' Replace <file path> below with an actual path.
        Dim csPrjPath As String = "<file path>"
        MsgBox("starting")
        ' Get the project template path for a C# console project.
        csTemplatePath = soln.GetProjectTemplate _
        ("ConsoleApplication.zip", "CSharp")
        ' Create a new C# Console project using the template obtained 
        ' above.
        soln.AddFromTemplate(csTemplatePath, csPrjPath, _
        "New CSharp Console Project", False)
        MsgBox("done")
    Catch ex As System.Exception
        MsgBox(ex.ToString)
    End Try
End Sub
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.
    SolutionExample((DTE2)_applicationObject);
}

public void SolutionExample(DTE2 dte)
{
    // This function creates a solution and adds a Visual C# Console
    // project to it.
    try{
        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("ConsoleApplication.zip", "CSharp");
        // Create a new C# Console project using the template obtained 
        // above.
        soln.AddFromTemplate(csTemplatePath, csPrjPath,
 "New CSharp Console Project", false);
        MessageBox.Show("Done!");
    }
    catch(SystemException ex)
    {
        MessageBox.Show("ERROR: " + ex);
    }
}

Voir aussi

Référence

Membres Solution2

EnvDTE80, espace de noms