Apparently there is a bug in TLBIMP which means that, under
certain circumstances, the interop DLL that it generates won’t
support events properly. This is probably a well-known issue that
everyone except me knows about, but I didn’t find too much about it
on Google.

For example, capturing events from Windows Messenger doesn’t
work by default and
you need
to take the following steps

  1. Use Tlbimp.exe to generate a Messenger interop assembly
    (this is located in C:Program FilesMessenger by

    tlbimp msmgs.exe /out:Messenger.dll
  2. Disassemble the interop assembly, and then save it as an IL

    ildasm /text Messenger.dll /
  3. Open the IL file in any text editor, and then change the
    following line (mark the class as public instead of private):

    .class private auto ansi sealed DMsgrObjectEvents_SinkHelper


    .class public auto ansi sealed DMsgrObjectEvents_SinkHelper

    and just below that

    .class private auto ansi sealed DMsgrObjectEvents_EventProvider


    .class public auto ansi sealed DMsgrObjectEvents_EventProvider
  4. Compile the IL file:
    ilasm /dll
  5. This DLL is now ready to be referenced in a