Reference3.Remove 方法
将引用从包含它的 References 对象中移除。
命名空间: VSLangProj80
程序集: VSLangProj80(在 VSLangProj80.dll 中)
语法
声明
Sub Remove
void Remove()
void Remove()
abstract Remove : unit -> unit
function Remove()
示例
这将向打开的 Visual Basic 或 Visual C# 项目添加引用,然后再将其移除。 若要将此示例作为外接程序运行,请参见如何:编译和运行自动化对象模型代码示例。
所添加的引用的默认路径为:<安装根目录>\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 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关详细信息,请参阅通过部分受信任的代码使用库。