Solution2-Schnittstelle

Aktualisiert: November 2007

Stellt alle Projekte und projektmappenweiten Eigenschaften in der integrierten Entwicklungsumgebung (IDE) dar.

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

Syntax

<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

Hinweise

Das Solution-Objekt ist eine Auflistung aller Projekte in der aktuellen Instanz der IDE und aller projektmappenweiten Eigenschaften, z. B. Buildkonfigurationen. Das Solution-Objekt enthält unabhängig davon, ob es sich um ein eingeschlossenes Projekt, ein Unterprojekt oder ein Projekt auf oberster Ebene handelt, für jedes Projekt ein Projektelement.

Auf dieses Objekt können Sie mit DTE.Solution verweisen. Verwenden Sie Solution.Item(EnvDTE.Constants.vsProjectKindMisc) oder Solution.Item(EnvDTE.Constants.vsProjectKindSolutionItems), um auf virtuelle Projekte wie MiscFiles oder SolutionItems zu verweisen.

Beispiele

Informationen zum Ausführen des Add-In-Codes finden Sie unter Gewusst wie: Kompilieren und Ausführen der Codebeispiele für das Automatisierungsobjektmodell.

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);
    }
}

Siehe auch

Referenz

Solution2-Member

EnvDTE80-Namespace