This documentation is archived and is not being maintained.

Reference3.Remove Method 

Removes the reference from the References object that contains it.

Namespace: VSLangProj80
Assembly: VSLangProj80 (in vslangproj80.dll)

void Remove ()
void Remove ()
function Remove ()

This adds a reference to an open Visual Basic, Visual C#, or Visual J# 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.

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, C#, or J# 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...");