how to use berkeley-db on 64bit windows?
785450Jul 16 2010 — edited Jul 19 2010Hi,
I'm using berkeley-db5.0.21 with C# wrapper in my application, it works fine on 32bit windows. However, when I tried my app on 64bit windows, it came with the error:
--------------------------------------------------------------------------------
The type initializer to System.TypeInitializationException: “BerkeleyDB.Internal.libdb_csharpPINVOKE” threw an exception. ---> System.TypeInitializationException: The type initializer to “SWIGStringHelper” threw an exception. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT:0x8007000B)
At BerkeleyDB.Internal.libdb_csharpPINVOKE.SWIGStringHelper.SWIGRegisterStringCallback_libdb_csharp(SWIGStringDelegate stringDelegate)
At BerkeleyDB.Internal.libdb_csharpPINVOKE.SWIGStringHelper..ctor()
At BerkeleyDB.Internal.libdb_csharpPINVOKE..cctor() At C:\Users\gmf\hg\db-5.0.21\csharp\Internal\libdb_csharpPINVOKE.cs:line 33
At BerkeleyDB.Internal.libdb_csharpPINVOKE.new_DB(HandleRef jarg1, UInt32 jarg2)
At BerkeleyDB.Internal.DB..ctor(DB_ENV env, UInt32 flags) At C:\Users\gmf\hg\db-5.0.21\csharp\Internal\DB.cs:line 109
At BerkeleyDB.BaseDatabase..ctor(DatabaseEnvironment envp, UInt32 flags) At C:\Users\gmf\hg\db-5.0.21\csharp\BaseDatabase.cs:line 35
At BerkeleyDB.BTreeDatabase..ctor(DatabaseEnvironment env, UInt32 flags) At C:\Users\gmf\hg\db-5.0.21\csharp\BTreeDatabase.cs:line 30
This should be normal because the installed bdb is 32bit by default. Then I re-built Berkeley DB(build_windows\BDB_dotNet.sln) to x64, and copied the built "libdb50d.dll, libdb_csharp50d.dll"(removed the last "d" char) to the installation directory to replace the original dlls and rerun my app, but still failed with the different error:
--------------------------------------------------------------------------------
The type initializer to System.TypeInitializationException: “BerkeleyDB.Internal.libdb_csharpPINVOKE” threw an exception。 ---> System.TypeInitializationException: The type initializer to “SWIGStringHelper” threw an exception. ---> System.DllNotFoundException: Could not load file or assembly “libdb_csharp50”: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT:0x800736B1)。
At BerkeleyDB.Internal.libdb_csharpPINVOKE.SWIGStringHelper.SWIGRegisterStringCallback_libdb_csharp(SWIGStringDelegate stringDelegate)
At BerkeleyDB.Internal.libdb_csharpPINVOKE.SWIGStringHelper..ctor()
At BerkeleyDB.Internal.libdb_csharpPINVOKE..cctor() At C:\Users\gmf\hg\db-5.0.21\csharp\Internal\libdb_csharpPINVOKE.cs:line 33
At BerkeleyDB.Internal.libdb_csharpPINVOKE.new_DB(HandleRef jarg1, UInt32 jarg2)
At BerkeleyDB.Internal.DB..ctor(DB_ENV env, UInt32 flags)At C:\Users\gmf\hg\db-5.0.21\csharp\Internal\DB.cs:line 109
At BerkeleyDB.BaseDatabase..ctor(DatabaseEnvironment envp, UInt32 flags) At C:\Users\gmf\hg\db-5.0.21\csharp\BaseDatabase.cs:line 35
At BerkeleyDB.BTreeDatabase..ctor(DatabaseEnvironment env, UInt32 flags) At C:\Users\gmf\hg\db-5.0.21\csharp\BTreeDatabase.cs:line 30
At BerkeleyDB.BTreeDatabase.Open(String Filename, String DatabaseName, BTreeDatabaseConfig cfg, Transaction txn) At C:\Users\gmf\hg\db-5.0.21\csharp\BTreeDatabase.cs:line 229
Am I doing something wrong with the build of x64 version? Or is there other steps needed to do to use x64 bdb? Any help is appreciated.