从 C# 导出 VirtualChannelGetInstance 函数

Export VirtualChannelGetInstance function from c#

我想从 C# 导出这个函数:

HRESULT VCAPITYPE VirtualChannelGetInstance(
 _In_    REFIID refiid,
 _Inout_ ULONG  *pNumObjs,
 _Out_   VOID   **ppObjArray
);

我试过以下代码:

public static uint VirtualChannelGetInstance(IntPtr refiid, ref uint pNumObjs, ref IntPtr[] ppObjArray)  
{
      MessageBox.Show("VirtualChannelGetInstance ");
      return 0; 
}

问题是当调用这个从 C# 导出的函数时,我总是得到 nullreference 异常。可能是什么问题?

我通过更改 VirtualChannelGetInstance 声明使它工作:

public static uint VirtualChannelGetInstance(Guid refiid, ref ulong pNumObjs, void** ppObjArray)