Metodo Solution4.Remove (Project)

Rimuove il progetto specificato dalla soluzione.

Spazio dei nomi:  EnvDTE100
Assembly:  EnvDTE100 (in EnvDTE100.dll)

Sintassi

'Dichiarazione
Sub Remove ( _
    proj As Project _
)
void Remove(
    Project proj
)
void Remove(
    [InAttribute] Project^ proj
)
abstract Remove : 
        proj:Project -> unit 
function Remove(
    proj : Project
)

Parametri

  • proj
    Tipo: EnvDTE.Project
    Obbligatorio.Il progetto che deve essere rimosso dalla soluzione.

Esempi

Per informazioni sulla modalità di esecuzione di questo codice di componente aggiuntivo, vedere Procedura: compilare ed eseguire gli esempi di codice del modello a oggetti di automazione.

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)
    SolnRemoveExample(_applicationObject)
End Sub

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

    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 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.
    SolnOpenExample((DTE2)_applicationObject);
}

public void SolnOpenExample(DTE2 dte)
{
    // This add-in 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);
    }
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

Solution4 Interfaccia

Overload Remove

Spazio dei nomi EnvDTE100

Altre risorse

Procedura: compilare ed eseguire gli esempi di codice del modello a oggetti di automazione