Condividi tramite


Metodo Reference3.Remove

Rimuove il riferimento da References l'oggetto che lo contiene.

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

Sintassi

'Dichiarazione
Sub Remove
void Remove()
void Remove()
abstract Remove : unit -> unit 
function Remove()

Esempi

Viene così aggiunto un riferimento a un elemento aperto Visual Basic o Visual C# il progetto e quindi lo rimuove.Per eseguire questo esempio viene illustrato come componente aggiuntivo, vedere Procedura: compilare ed eseguire gli esempi di codice del modello a oggetti di automazione.

I percorsi predefiniti per il riferimento aggiunto viene: <radice dell'installazione> \Program Files\Microsoft SQL Server\90\SDK\Assemblies.di sostituzione <percorso del file> nell'esempio a l o un altro percorso del file appropriato.

Imports VSLangProj
Imports VSLangProj2
Imports VSLangProj80
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)
    TestRemove(applicationObject)
End Sub
Public Sub TestRemove(ByVal dte As DTE2)
    ' The first project is a Visual Basic or C# project.
    Dim vsProject As VSProject2 = _
    CType(dte.Solution.Projects.Item(1).Object, VSProject2)
    ' Add a reference.
    Dim newRef As Reference3
    ' Replace <file path> with an actual file path.
    newRef = CType(vsProject.References.Add
("<file path>\Microsoft.SqlServer.Smo.dll"), _
    Reference3)
    MsgBox("Added a reference " & newRef.Name)
    newRef.Remove()
    MsgBox("Removed the reference...")
End Sub
using System.Windows.Forms;
using VSLangProj;
using VSLangProj2;
using VSLangProj80;
public void OnConnection(object application,
 ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    applicationObject = (DTE2)application;
    addInInstance = (AddIn)addInInst;
    TestRemove(((DTE2)applicationObject));
}
public void TestRemove(DTE2 dte)
{
    // The first project is a Visual Basic or C# project.
    VSProject2 aProject =
((VSProject2)(applicationObject.Solution.Projects.Item(1).Object));
    Reference3 aRef = null;
    // Replace <file path> with an actual file path.
    aRef = (Reference3)aProject.References.Add
(@"<file path>\ Microsoft.SqlServer.Smo.dll ");
    MessageBox.Show("Added a new reference " + aRef.Name);
    aRef.Remove();
    MessageBox.Show("removed the reference...");
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

Reference3 Interfaccia

Overload Remove

Spazio dei nomi VSLangProj80