Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. C# and COM Events

C# and COM Events

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpc++comquestion
2 Posts 2 Posters 6 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Per Nilsson
    wrote on last edited by
    #1

    Hello all I have a project where I from C# code need to use a COM object and consume events. My COM object can send events by the use of Connectable Objects. In the good old days when C++ and COM were used, I used the IConnectionPoint and Advice. But, is there in .NET a way to consume COM events? I guess it will be in the System.Runtime.InteropServices.

    Richard DeemingR 1 Reply Last reply
    0
    • P Per Nilsson

      Hello all I have a project where I from C# code need to use a COM object and consume events. My COM object can send events by the use of Connectable Objects. In the good old days when C++ and COM were used, I used the IConnectionPoint and Advice. But, is there in .NET a way to consume COM events? I guess it will be in the System.Runtime.InteropServices.

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      For an early-bound library, you should be able to add event handlers in the same way as any other .NET class. For a late-bound library, you'll want to use the System.Runtime.InteropServices.ComTypes.IConnectionPoint interface[^], which should be familiar to you from C++. :) IIRC, the event sink parameter to the Advise method needs to be public, [ComVisible(true)], and [ClassInterface(ClassInterfaceType.None)].


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups