Receiving Virtual Server events from a managed program

Last week I talked about how to receive Virtual Server events from a VBScript – this week I am going to talk about doing this from a managed application.  To do this you need to:

  1. Setup the managed application appropriately to talk to the Virtual Server COM interfaces (details here:

  2. Declare your Virtual Server COM object ‘WithEvents’ as follows:

    Private WithEvents virtualServer As VMVirtualServer = Nothing

    instead of:

    Private virtualServer As VMVirtualServer = Nothing

  3. Create a subroutine to catch the event:

    Public Sub virtualServer_EventLogged(ByVal logMessageID As Integer) Handles virtualServer.OnEventLogged

         ‘Do something with the event

    End Sub

There – really quite simple.