2010-08-21 41 views
0

我正在使用Microsoft Visual C++從命令行編譯一個32位和64位SQLite庫,以實現簡單的C#包裝。 32位版本可以正常工作,但當sqlite3_prepare_v2返回除SQLITE_OK之外的任何內容時,64位版本會完全崩潰我的應用程序。當sqlite3_prepare_v2失敗時,SQLite 64位庫崩潰

的build.bat

set ARGS=/nologo /LD /DSQLITE_ENABLE_COLUMN_METADATA sqlite3.c /link /def:sqlite3.def 

call vcvars32.bat 
cl %ARGS% /out:sqlite3.dll 

call vcvars64.bat 
cl %ARGS% /out:sqlite3_64.dll 

C#代碼(相關比特)

public delegate int _sqlite3_prepare_v2(IntPtr db, string zSql, int nByte, out IntPtr ppStmt, out IntPtr pzTail); 

public static readonly _sqlite3_prepare_v2 sqlite3_prepare_v2; 

IntPtr tail; 
if (SQLite.sqlite3_prepare_v2(_db.Handle, text, -1, out _handle, out tail) != SQLite.SQLITE_OK) 
    throw new SQLiteException(_db); 

的功能是在運行時綁定,這樣我可以編譯爲任何CPU和選擇的哪個版本要使用的庫。當我在64位系統上運行這個時,我得到:

vshost-clr2.exe has stopped working 
Problem signature: 
    Problem Event Name:  APPCRASH 
    Application Name:   SQLiteTest.vshost.exe 
    Application Version:  10.0.30319.1 
    Application Timestamp: 4ba2084b 
    Fault Module Name:  StackHash_4a05 
    Fault Module Version:  6.1.7600.16559 
    Fault Module Timestamp: 4ba9b802 
    Exception Code:   c0000374 
    Exception Offset:   00000000000c6df2 
    OS Version:    6.1.7600.2.0.0.256.48 
    Locale ID:    1033 
    Additional Information 1: 4a05 
    Additional Information 2: 4a055724055f1d4270656b7cd547877a 
    Additional Information 3: 92b7 
    Additional Information 4: 92b737f393457f0de2d4edb6b32c0617 

任何想法?

編輯:調試應用程序時,我得到的消息是:

堆已損壞

回答

0

SQLITE_MISUSE意味着你使用的庫在一個糟糕的方式。如果你可以改變你的代碼,以不觸發它在32位,我懷疑你的64位崩潰將消失。

+0

對不起,我把日誌中的電話混淆了。 'sqlite3_prepare_v2'沒有返回'SQLITE_MISUSE',但'sqlite3_step'是因爲sqlite3_prepare_v2'在表格試圖再次創建時返回'SQLITE_ERROR'。 64位崩潰必須是別的東西。 – 2010-08-21 16:23:15