0

I'm creating a COM-object and can call all of its methods, get and set properties using comType.InvokeMember with different BindingFlags. The COM-object has a very huge interface, so it will be a lot of work for me to define it, and the object implements IDispatch.

Is there a way to add event handler for one of the object's events using reflection? I tried using comType.GetEvent to get EventInfo, but it could find it. Also there are no events found by comType.GetEvents either.

user2102508
  • 1,009
  • 11
  • 23
  • You don't *have to* "define" interfaces etc. you can use the `dynamic` c# keyword. Here is how it can work with dynamic: https://stackoverflow.com/questions/8694235/attach-event-to-dynamic-object (basically, you'll still have to define a delegate) – Simon Mourier Jan 16 '19 at 15:27
  • @SimonMourier sadly I can't use it as I'm on .NET 3.5. – user2102508 Jan 17 '19 at 09:04
  • Well, there are add_EventName method, but I can't figure out how to call it with InvokeMember. – user2102508 Jan 17 '19 at 13:08

0 Answers0