我正在使用C#來調用DLL函數。在interop方法中傳遞`ref struct`參數的`null`引用
[DllImport("MyDLL.dll", SetLastError = true)]
public static extern uint GetValue(
pHandle handle,
ref somestruct a,
ref somestruct b);
如何通過參數3的null
參考?
當我嘗試,我得到一個編譯時錯誤:
Cannot convert from
<null>
to ref somestruct.
我也試過IntPtr.Zero
。
它是'ref'參數?那麼你爲什麼不告訴我們確切的方法簽名? 'somestruct'真的是一個結構還是一個類? – 2013-03-05 06:50:55
修復它。它是一個結構 – user1964059 2013-03-05 06:52:06
可以這篇文章http://msdn.microsoft.com/en-us/library/1t3y8s4s(v=vs.80).aspx幫助你嗎? – 2013-03-05 06:59:49