An interface method cannot be static
or extern
. It doesn't make any sense. In COM in particular, an interface always requires a class instance obtained from IClassFactory::CreateInstance(), etc. That's just the way COM works. In C# in turn, a static
method cannot be an implementation of an interface method, even if it has the right parameters and name, for the same reason: a C# interface reference is obtained from casting an object (instance) reference to the interface.
And it makes total sense! Remember that underlying every interface method call there is a hidden (By C++ and C#) this
argument that references the object instance. The method signatures don't really match, even if it looks that way on the surface.
If you need to expose the same method both as a COM method and as a plain C external symbol, you will need two copies of the method declaration: the static extern
one which implements the functionality, and a second copy that forwards the call, which is declared as public int IComNativeCallsInterface.Convert(ref formatfile fptr)
. If I remember correctly (I don't have a computer with VS at hand), by declaring the second method as an explicit interface implementation you will be able to have the two declarations match name and formal arguments exactly without a conflict.