Reference3.Remove Method


Removes the reference from the References object that contains it.

 void Remove();
 void Remove();
void Remove();
public void Remove ();
abstract member Remove : unit -> unit
Public Sub Remove ()




This adds a reference to an open Visual Basic or Visual C# project, and it then removes it. To run this example as an add-in, see How to: Compile and Run the Automation Object Model Code Examples.

The default paths for the added reference is: <installation root>\Program Files\Microsoft SQL Server\90\SDK\Assemblies. Replace <file path> in the example with this or another appropriate file path.

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)  
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"), _  
    MsgBox("Added a reference " & newRef.Name)  
    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;  
public void TestRemove(DTE2 dte)  
    // The first project is a Visual Basic or C# project.  
    VSProject2 aProject =  
    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);  
    MessageBox.Show("removed the reference...");  

Applies to