Skip to content

.NET COM events using IDispatch are not handled #873

Open

Description

@spynetcamera

In C#, as a guideline, events are exposed by an IDispatch interface for late-binding only, by using the attribute [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)].

It seems like there's no way to sink those events, a code like follows:

class IEvents():
    def IEvents_OnResult(self, this, result):
        print(f"Event! {result}")

from comtypes.client import GetEvents
sink = IEvents()
connection = GetEvents(obj, sink)

will cause the error _ctypes.COMError: (-2147467263, 'Not implemented', ('The method or operation is not implemented.', 'mscorlib', None, 0, None))

Is there a way to handle this use case?

Thanks

Activity

  1. junkmd commented on Oct 12, 2025

    @junkmd
    Collaborator

    COM event handling is consistently one of the more challenging areas for this project.
    Moreover, dealing with event sinking through late-bind only interfaces adds significant complexity.

    To help us investigate this issue further, would you be able to provide a minimal reproducer for the C# COM server and event you are using?
    This would be extremely helpful for isolating and debugging the problem.

  2. spynetcamera commented on Oct 14, 2025

    @spynetcamera
    Author
  3. junkmd commented on Oct 31, 2025

    @junkmd
    Collaborator

    No file is attached.
    Could you share the files on your public repository?

  4. spynetcamera commented on Nov 1, 2025

    @spynetcamera
    Author

    DemoCOM (NET Framework).zip

    Here you go, I have attached to email and just realized it is not visible on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions