1

已知 DllImport(..., PreserveSig=false) 属性在Mono中有效吗?

我在 C 中声明了一个导出的 dll 函数:

HRESULT MyFunction(INTPTR* psomehandle);

在 C# 方面,我这样声明:

[DllImport("MyDll", PreserveSig=false)]
IntPtr MyFunction();

这在 MS.NET 中按预期工作,但在 Mono 中崩溃,因为 'psomehandle' 作为 NULL 传递。


以下声明不会导致崩溃,但如果 E_FAIL 从 MyFunction 返回,则不会引发异常。

[DllImport("MyDll", PreserveSig=false)]
void MyFunction(out IntPtr somehandle);

我已经在 Windows 上使用 Mono 2.6.7 和 2.10.9 进行了尝试。

4

0 回答 0