Hello all,
1. I have recently made a report to Microsoft Connect regarding a possible bug in the CLR code that handles COM events fired from unmanaged COM servers :
2. Since then, I have been doing research on the internals of the flow of event firing from an unmanaged COM server's IDispatch::Invoke() method call right down to the invokation of the managed object's event handler delegate function.
3. I have managed to find some interesting information about a ComEventsSink class from :
COMEventsSink.cs
4. This class provides an implementation for IDispatch and is used by the ComEventsHelper and the ComEventsInfo classes. Its Invoke() method provided very good info to me and there is a hint on why an event method which takes a SAFEARRAY reference parameter
winds up returning E_INVALIDARG (an ArgumentException exception is thrown).
5. I also had a look at the *_SinkHelper class declared in the disassembled IL code of the interop assembly generated by tlbimp.exe for an unmanaged COM server. I see that it directly calls the Invoke() method of the delegate with no reference to any ComEventsSink
object.
6. It is pretty clear that there must be some IDispatch implementation behind the SinkHelper class that gets called by the COM server event firing code.
7. Since the SinkHelper class is derived from System.Object, I believe that the SinkHelper probably inherits this IDispatch implementation of the System.Object class.
9.It is also possible that System.Object may internally use the ComEventsSink class to handle COM events.
10. I was wondering if anyone has any knowledge of this IDispatch implementation ?
11. Thanks, all.
- Bio.
Please visit my blog : http://limbioliong.wordpress.com/