This is just a question on how to write my code for a COM import.
My understanding of the correct implementation of interop interfaces is that the main criteria is that:
- All method signatures must match in a compatible way
- Methods must appear in exactly the same order in the .Net interface as they do in the unmanaged interface
- When the unmanaged interface inherits from another unmanaged interface, the managed implementation must first declare the base-level interface members, starting with the base-most interface.
My question is; what do I do, with respect to the order in which the members appear, if the interface I am importing is inherited from another interface and overrides/hides one or more of the members in the base interface? Where does the interface member declaration go? First, where the base interface declared it? Or removed from its original position and placed where the derived interface declares it?
[uuid(31d1c294-1dd2-11b2-be3a-c79230dca297)]
interface BaseComInterface
{
void method1();
void method2();
void method3();
}
[uuid(fab51c92-95c3-4468-b317-7de4d7588254)]
interface DerivedComInterface : BaseComInterface
{
void method1();
void method4();
void method5();
}
Now for the C# code:
[Guid("fab51c92-95c3-4468-b317-7de4d7588254"), ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDerivedComInterface
{
void method1(); // do I remove this one?
void method2();
void method3();
void method1(); // or this one?
void method4();
void method5();
}