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 Files\Messenger by default):

    tlbimp msmgs.exe /out:Messenger.dll
    
  2. Disassemble the interop assembly, and then save it as an IL file:
    ildasm /text Messenger.dll /out:Messenger.il
    
  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
    
    to
    .class public auto ansi sealed DMsgrObjectEvents_SinkHelper
    
    and just below that
    .class private auto ansi sealed DMsgrObjectEvents_EventProvider
    
    to
    .class public auto ansi sealed DMsgrObjectEvents_EventProvider
    
  4. Compile the IL file:
    ilasm /dll Messenger.il
    
  5. This DLL is now ready to be referenced in a project.
posted on Thursday, November 28, 2002 12:07 AM |
Comments have been closed on this topic.