Sdílet prostřednictvím


SolutionFolder-Schnittstelle

Aktualisiert: November 2007

Projektmappenordner sind Projektcontainer, mit denen Entwickler große Anwendungen besser organisieren können.

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

Syntax

'Declaration
<GuidAttribute("F8F69788-267C-4408-8967-74F26108C438")> _
Public Interface SolutionFolder
'Usage
Dim instance As SolutionFolder
[GuidAttribute("F8F69788-267C-4408-8967-74F26108C438")]
public interface SolutionFolder
[GuidAttribute(L"F8F69788-267C-4408-8967-74F26108C438")]
public interface class SolutionFolder
public interface SolutionFolder

Hinweise

In Visual Studio 2005 können Projektmappen nicht Projektordner, sondern auch Projektmappenordner enthalten. Projektmappenordner sind Projektcontainer, mit denen Entwickler große Anwendungen besser organisieren können.

Die Projects-Eigenschaft der Projektmappe gibt eine Auflistung von Project-Objekten zurück. Jedes einzelne Projekt verfügt über eine Kind-Eigenschaft, die auf vsProjectKindSolutionFolder festgelegt werden kann. Um zu der SolutionFolder-Schnittstelle zu gelangen, rufen Sie Project.Object auf, und wandeln Sie dann das zurückgegebene Objekt in einen SolutionFolder-Typ um.

Beispiele

In diesem Beispiel wird ein neuer Projektmappenordner erstellt und ihm aus einer vorhandenen Datei ein Projekt hinzugefügt. Erstellen Sie vor dem Ausführen des Beispiels auf dem Hauptlaufwerk ("C:" in diesem Fall) den Ordner "Projects" sowie in diesem Ordner ein Visual C#-Klassenbibliotheksprojekt mit dem Namen "ClassLibrary1". Zudem müssen Sie vor dem Ausführen dieses Add-Ins in der integrierten Entwicklungsumgebung (Integrated Development Environment – IDE) von Visual Studio ein Projekt öffnen.

Weitere Informationen zum Ausführen dieses Beispiels als Add-In finden Sie unter Gewusst wie: Kompilieren und Ausführen der Codebeispiele für das Automatisierungsobjektmodell.

Imports EnvDTE
Imports EnvDTE80
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)
    solnFolderAddFromFileExample(_applicationObject)
End Sub
Sub solnFolderAddFromFileExample(ByVal dte As DTE2)
    ' Before running this example, create a "Projects" folder
    ' off your main drive (C: in this example), and create a C# 
    ' class library project, named ClassLibrary1 in that folder.
    Dim soln As Solution2 = CType(_applicationObject.Solution _
    , Solution2)
    Dim prj As Project
    Dim SF As SolutionFolder
    Try
        Dim prjPath As String = _
        "C:\Projects\ClassLibrary1\ClassLibrary1\ClassLibrary1.csproj"
        ' Open a project in the Visual Studio IDE before running 
        ' this add-in.
        ' Add a solution folder.
        prj = soln.AddSolutionFolder("A new soln folder")
        SF = CType(prj.Object, SolutionFolder)
        ' Add a project to the new solution folder.
        SF.AddFromFile(prjPath)
        MsgBox("Added a new solution folder that contains a _
        C# project named ClassLibrary1.")
    Catch ex As System.Exception
        MsgBox(ex.ToString)
    End Try
End Sub
using EnvDTE;
using EnvDTE80;
using System.Windows.Forms;
public void OnConnection(object application, 
ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    solnFolderAddFromFileExample(_applicationObject);
}
public void solnFolderAddFromFileExample(DTE2 dte)
{
    // Before running this example, create a "Projects" folder
    // off your main drive (C: in this example), and create a C# 
    // class library project, named ClassLibrary1 in that folder.
    Solution2 soln = (Solution2)_applicationObject.Solution;
    Project prj;
    SolutionFolder SF;
    try
    {
        String prjPath =
 "C:\\Projects\\ClassLibrary1\\ClassLibrary1\\ClassLibrary1.csproj";
        // Open a project in the Visual Studio IDE before running 
        // this add-in.
        // Add a solution folder.
        prj = soln.AddSolutionFolder("A new soln folder");
        SF = (SolutionFolder)prj.Object;
        // Add a project to the new solution folder.
        SF.AddFromFile(prjPath);
    MessageBox.Show("Added a new solution folder that contains a 
C# project named ClassLibrary1.");
    }
    catch(SystemException ex)
    {
        MessageBox.Show(ex.ToString());
    }
}

Siehe auch

Referenz

SolutionFolder-Member

EnvDTE80-Namespace