1
我需要在C#中调用C++中的以下(DirectShow相关)COM接口。C#COM接口继承
我在C#中声明如下,但是当调用IFoo.Foo()时,它与Access Violation一起崩溃。工作正常与IBar.Bar()被称为虽然。在C#中编写等价接口的正确方法是什么?
[ComImport, Guid("...)]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[SuppressUnmanagedCodeSecurity]
public interface IBar
{
[PreserveSig] int Bar(); // Calling this is OK
}
[ComImport, Guid("...)]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[SuppressUnmanagedCodeSecurity]
public interface IFoo : IBar
{
[PreserveSig] int Foo(); // Calling this crashes
}
的虚函数表必须是对C++对继承COM接口在C#不相容。有没有办法告诉C#遵守C++声明?