Compartilhar via


Solution2.Remove(Project) Method

Definition

Removes the specified project from the solution.

public:
 void Remove(EnvDTE::Project ^ proj);
public:
 void Remove(EnvDTE::Project ^ proj);
void Remove(EnvDTE::Project const & proj);
[System.Runtime.InteropServices.DispId(25)]
public void Remove (EnvDTE.Project proj);
[<System.Runtime.InteropServices.DispId(25)>]
abstract member Remove : EnvDTE.Project -> unit
Public Sub Remove (proj As Project)

Parameters

proj
Project

Required. The project to remove from the solution.

Implements

Attributes

Examples

Sub SolnRemoveExample(ByVal dte As DTE2)  
    ' Removes a project from a solution.  
    ' Open a solution that contains at least one project   
    ' in Visual Studio before running this example.  

    Dim soln As Solution2 = CType(dte.Solution, Solution2)  
    Dim proj As Project = soln.Projects.Item(1)  

    Try  
        ' Delete the first project in the solution.   
        MsgBox("Ready to delete the project.")  
        soln.Remove(proj)  
        MsgBox("Project was deleted from the solution.")  

        ' Close the solution from the IDE.  
        soln.Close()  
    Catch ex As SystemException  
        MsgBox("ERROR: " & ex.ToString())  
    End Try  
End Sub  
using System.Windows.Forms;  

public void SolnOpenExample(DTE2 dte)  
{  
    // Removes the first project from a solution.  
    // Open a solution that contains at least one project before  
    // running this example.  
    Solution2 soln = (Solution2)_applicationObject.Solution;  
    Project proj = soln.Projects.Item(1);  
    try  
    {  
        // Delete the first project in the solution.  
        MessageBox.Show("Ready to delete the project.");  
        soln.Remove(proj);  
        MessageBox.Show("Project was deleted from the solution.");  
        // Close the solution from the IDE.  
        soln.Close(false);  
    }  
    catch (SystemException ex)  
    {  
        MessageBox.Show("ERROR: " + ex);  
    }  
}  

Applies to