none
Implement COM Event Interface RRS feed

  • Question

  • There is a COM library that define COM event interface as:

        [InterfaceType(1)]
        [Guid("A066D11D-9D0C-11D3-9FD5-00C04F6BC6A5")]
        [TypeLibType(256)]
        public interface IAnnotationErrorEvents
        {
            void ErrorAddingElements();
            bool TooManyOverflow(int numOverflow);
        }
    I need to implement this event interface in my .NET object. MSDN library says that interface has to have attribute [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] to be able to implement it in .NET object.

    But in my case I don't specify interface in my code. It is imported from existent library and it is already defined as [InterfaceType(1)]. It is equivalent to [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)].

    As I understand implementation has to be like next code in case when InterfaceType is correct
    [ClassInterface(ClassInterfaceType.None)]
    [ComSourceInterfaces(typeof(IAnnotationErrorEvents))]
    class ImplementationClass
    {
    public event IAnnotationErrorEvents_ErrorAddingElementsEventHandler ErrorAddingElements;

    public

     

    event IAnnotationErrorEvents_TooManyOverflowEventHandler TooManyOverflow;

    }
    Is there any way to implement such Event Interface with InterfaceIsIUnknown?

    Friday, December 11, 2009 5:35 PM

Answers

All replies