Reference3.Remove 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
从包含引用的对象中移除引用 References 。
public:
void Remove();
public:
void Remove();
void Remove();
[System.Runtime.InteropServices.DispId(4)]
public void Remove ();
[<System.Runtime.InteropServices.DispId(4)>]
abstract member Remove : unit -> unit
Public Sub Remove ()
实现
- 属性
示例
这会添加对打开的 Visual Basic 或项目的引用 Visual C# ,然后将其删除。 若要将此示例作为外接程序运行,请参阅 如何:编译和运行自动化对象模型代码示例。
添加的引用的默认路径为: <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...");
}