次の方法で共有


Reference3.Remove メソッド

参照を含む References オブジェクトから参照を削除します。

名前空間:  VSLangProj80
アセンブリ:  VSLangProj80 (VSLangProj80.dll 内)

構文

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

実装

Reference2.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...");
}

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

Reference3 インターフェイス

Remove オーバーロード

VSLangProj80 名前空間