Share via


IDTExtensibility2.OnAddInsUpdate Method

Occurs whenever an add-in is loaded or unloaded from the Visual Studio integrated development environment (IDE).

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

Syntax

'Declaration
Sub OnAddInsUpdate ( _
    ByRef custom As Array _
)
void OnAddInsUpdate(
    ref Array custom
)
void OnAddInsUpdate(
    [InAttribute] Array^% custom
)
abstract OnAddInsUpdate : 
        custom:Array byref -> unit 
function OnAddInsUpdate(
    custom : Array
)

Parameters

  • custom
    Type: System.Array%
    An empty array that you can use to pass host-specific data for use in the add-in.

Remarks

This method is most often used to enforce dependencies on other add-ins. That is, if an add-in requires the presence of another add-in (or other program) before it can run properly, you can check the status with this method.

An add-in triggers the OnAddInsUpdate event when an add-in loads in the environment for the first time in that session, and whenever the OK button in the Add-In Manager is clicked. It does not trigger when an add-in is loaded by a command or when it is loaded by way of its Connected property.

To obtain the name of the add-in that has changed, iterate through the AddIns collection and check each add-in's Connected property. You can access each add-in by using either its ProgID or 1-based index value. If the index does not exist, an "invalid index" COMException error occurs. Otherwise, it returns an AddIn reference.

Examples

Public Sub OnAddInsUpdate(ByRef custom As Array) 
    Try
        Dim addIn As AddIn = applicationObject.AddIns. _
        Item("MyAddin1.Connect")
        If addInInstance.Connected = True Then
            System.Windows.Forms.MessageBox.Show("This add-in is _
            connected.")
        Else
            System.Windows.Forms.MessageBox.Show("This add-in is not _
            connected.")
        End If
    Catch ex As Runtime.Interop.COMException
        System.Windows.Forms.MessageBox.Show("Not a registered add- _
        in.")
    End Try
End Sub
public void OnAddInsUpdate(ref Array custom)
{
    try
    {
        AddIn addIn = this.dte.addins.item("MyAddin1.Connect");
        if (addInInstance.Connected == true)
        {
            System.Windows.Forms.MessageBox.Show("This add-in is 
            connected.");
        }
        else
        {
            System.Windows.Forms.MessageBox.Show("This add-in is not 
            connected.");
        }
    }

    catch (COMException)
    {
         System.Windows.Forms.MessageBox.Show("Not a registered add-
         in.");
    }
}

.NET Framework Security

See Also

Reference

IDTExtensibility2 Interface

Extensibility Namespace

IDTExtensibility2

OnConnection

OnDisconnection

OnBeginShutdown

OnStartupComplete

Other Resources

How to: Create an Add-In