IDTExtensibility2.OnConnection-Methode

Tritt ein, wenn ein Add-In in Visual Studio geladen wird.

Namespace:  Extensibility
Assembly:  Extensibility (in Extensibility.dll)

Syntax

'Declaration
Sub OnConnection ( _
    Application As Object, _
    ConnectMode As ext_ConnectMode, _
    AddInInst As Object, _
    ByRef custom As Array _
)
void OnConnection(
    Object Application,
    ext_ConnectMode ConnectMode,
    Object AddInInst,
    ref Array custom
)
void OnConnection(
    [InAttribute] Object^ Application, 
    [InAttribute] ext_ConnectMode ConnectMode, 
    [InAttribute] Object^ AddInInst, 
    [InAttribute] Array^% custom
)
abstract OnConnection : 
        Application:Object * 
        ConnectMode:ext_ConnectMode * 
        AddInInst:Object * 
        custom:Array byref -> unit 
function OnConnection(
    Application : Object, 
    ConnectMode : ext_ConnectMode, 
    AddInInst : Object, 
    custom : Array
)

Parameter

  • Application
    Typ: System.Object
    Ein Verweis auf DTE, eine Instanz der integrierten Entwicklungsumgebung (IDE), die das Stammobjekt des Visual Studio-Automatisierungsmodells darstellt.
  • AddInInst
    Typ: System.Object
    Ein AddIn-Verweis auf die eigene Instanz des Add-Ins.Dieser wird für die spätere Verwendung gespeichert, z. B. um die übergeordnete Auflistung für das Add-In zu bestimmen.
  • custom
    Typ: System.Array%
    Ein leeres Array zur Übergabe hostspezifischer Daten, die im Add-In verwendet werden.

Hinweise

OnConnection ist die Hauptmethode für IDTExtensibility2, da sie bei jedem Laden eines Add-Ins aufgerufen wird.Sie bildet beim Laden den Einstiegspunkt für ein Add-In, sodass Sie hier beliebigen Code einfügen bzw. eine andere Funktion aufrufen können, der bzw. die beim Starten des Add-Ins ausgeführt werden soll.

Beispiele

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)
    MsgBox("Add-in is connected.")
End Sub
public void OnConnection(object application, ext_ConnectMode 
connectMode, object addInInst, ref Array custom)
{
    applicationObject = (DTE2)application;
    addInInstance = (AddIn)addInInst;
    System.Windows.Forms.MessageBox.Show("Add-in has connected.");
}

.NET Framework-Sicherheit

Siehe auch

Referenz

IDTExtensibility2 Schnittstelle

Extensibility-Namespace

IDTExtensibility2

OnDisconnection

OnAddInsUpdate

OnBeginShutdown

OnStartupComplete

Weitere Ressourcen

Gewusst wie: Erstellen von Add-Ins