共用方式為


Reference3.Remove 方法

從包含參考的 References 物件中移除參考。

命名空間:  VSLangProj80
組件:  VSLangProj80 (在 VSLangProj80.dll 中)

語法

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

範例

這會將參考加入至開啟的 Visual Basic 或 Visual C# 專案中,然後再予以移除。若要將此範例當做增益集來執行,請參閱 HOW TO:編譯和執行 Automation 物件模型程式碼範例

新增的參考之預設路徑為:<installation root>\Program Files\Microsoft SQL Server\90\SDK\Assemblies。以這個或另一個適當的檔案路徑取代範例中的 <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)
    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...");
}

.NET Framework 安全性

請參閱

參考

Reference3 介面

Remove 多載

VSLangProj80 命名空間