Skip to content

.NET COM events using IDispatch are not handled #873

@spynetcamera

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

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