I want to expose a .NET class to COM. That's fairly easy:
- I create an interface in where I define the members of that class that should be ComVisible
- I define the DispId's of those members myself
- I define that the interface should be
ComVisible - I assign a
Guidto that interface - I create a class which implements that interface
No big deal. This all works.
But, now my question is: I have a few events in that class, that I want to expose to COM as well.
This should be no big deal either, but, when I look at some examples (f.i. code generated by MS' ComInterop tool), I see that the events are declared in a separate interface.
That is: the class that should be ComVisible, implements 2 interfaces:
- one interface which defines the regular methods and properties that should be
ComVisible - another interface that defines the events that should be
ComVisible.
Now, my question is: why is that ? What is the reason for this ?
Why are the ComVisible events defined in another interface, and why are they just not defined in the interface that contains the methods and properties that should be ComVisible?
What is the reasoning behind this ?