Registering New Components with Visual Studio Analyzer

If you want your component to generate Visual Studio Analyzer events, the first thing you must do is add code that will register the component with Visual Studio Analyzer. Add this code to your component's installation or startup code, depending on when you want to register your component. You can register your component with Visual Studio Analyzer at one of three times:

The following lists the steps you must take with code in your component in order to register that component with Visual Studio Analyzer:

  1. Create an instance of the event source installer object.

    The event source installer object is a COM object that provides methods for registering your component with the Visual Studio Analyzer Event Monitor. How you create this object depends on the language in which your component is written, as shown in the following table:

    Language Code to Create an Event Source Installer Instance
    Visual Basic
    dim mESI As MSVSAEventSourceInstaller 
    Set mESI = New MSVSAEventSourceInstaller

    — or —

    dim mESI As new MSVSAEventSourceInstaller 
    Visual C++
    HRESULT hr = CoCreateInstance(CLSID_VSA_ESI, NULL, CLSCTX_INPROC_SERVER, IID_ISystemDebugEventInstall,
     (void **)&m_pInstall);
    Visual J++
    static ISystemDebugEventInstallAuto m_ESA = null;
    private static void SampleCreateESA()
       {
          m_ESA = new MSVSAEventSourceInstaller();
       }

  2. Call the RegisterSource or RegisterDynamicSource methods of the event source installer object, so that your component is registered.

    The RegisterSource method registers your component as a normal component. Most components fall into this category. Use the RegisterDynamicSource method to register your component as a dynamic component, which generates events at defined intervals.

    The interface exposed by the event source installer object is not a dual interface; therefore, the version of the interface you use depends on the language in which your component is written:

    Language Event Installer Interface
    Visual Basic, Visual J++ IsystemDebugEventInstallAuto
    Visual C++ ISystemDebugEventInstall

    If your component is not COM-enabled, use the Visual Studio Analyzer standard RPC interface, VsaRpcl.

  3. Register any custom event categories you plan to use (optional).

    See Registering New Event Categories with Visual Studio Analyzer for information on how to do this.

  4. Register the events you plan to generate.

    See Registering New Events with Visual Studio Analyzer for information on how to do this.