0

我正在使用SQL Server的Filestream功能。 當我嘗試訪問以下方法:調用PInvoke OpenSqlFilestream函數時,堆棧不平衡

[DllImport("sqlncli10.dll", SetLastError = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] 
private static extern SafeFileHandle OpenSqlFilestream(string path, uint access, uint options, byte[] txnToken, uint txnTokenLength, Sql64 allocationSize); 

SafeFileHandle handle = OpenSqlFilestream(filePath, (uint)access, 0, txnToken, (uint)txnToken.Length, new Sql64(0)); 

是調用方法。

對PInvoke OpenSqlFilestream函數的調用使堆棧不平衡。這很可能是因爲託管的PInvoke簽名與非託管目標籤名不匹配。檢查PInvoke簽名的調用約定和參數是否與目標非託管簽名相匹配。

可能是什麼原因?

我使用Visual Studio 2010

回答

0

試試這個:

[DllImport("sqlncli11.dll", SetLastError = true, CharSet = CharSet.Unicode)] //sqlncli10.dll 

private static extern SafeFileHandle OpenSqlFilestream(String filestreamPath, UInt32 desiredAccess, UInt32 openOptions, Byte[] filestreamTransactionContext, UInt32 filestreamTransactionContextLength, Int64 allocationSize);