I just follow the instruction at
SQLite-on-Visual-Studio-with-NuGet-and-Easy-Instructions
and I can able to compile sample C# appliation with
"any cpu"
option.
But when I run application, if I choose
"prefer 32 bit"
option, my application crash:
"Unable to load DLL "SQLite.Interop.dll"
If I uncheck "prefer 32 bit" option it works fine on my 64 bit machine.
Why this happen?Any suggestion to fix it?
PS: I use 64 bit Windows 8. and I provide [x86] and [x64] folders for SQLite.
PS 1: Error:
System.TypeInitializationException: The type initializer for 'System.Data.SQLite.SQLiteFactory' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) at System.Data.SQLite.UnsafeNativeMethods.sqlite3_config_none(SQLiteConfigOpsEnum op) at System.Data.SQLite.SQLite3.StaticIsInitialized() at System.Data.SQLite.SQLiteLog.Initialize() at System.Data.SQLite.SQLiteFactory..cctor() --- End of inner exception stack trace --- at System.Data.SQLite.SQLiteFactory..ctor()
PS 3:
I notice an interesting thing. Although at visual studio it craches, when i run my program exe, by just clicking it, it works.
Run command prompt as Administrator. cd
into the directory with your x64 .dll. Then type: gacutil -i SQLite.Interop.dll
. Then cd
to the directory with the x86 .dll. Type again: gacutil -i SQLite.Interop.dll
. Now it should be working right.
What this does is installs each assembly into the GAC(Global Assembly Cache) on your system. It puts them into the proper system cache directory depending on how it was compiled(x86 or x64). This should only be used for debugging purposes.
GAC 32bit vs. 64bit
For a client machine. Do a deployment for x86 and for x64 each. Of course throw in the proper version of your .dll for each.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With