0

I am trying to create the object of SQLiteConnection which is giving an error

Could not load file or assembly 'System.Data.SQLite, Version=1.0.94.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Its working fine I check Prefer 32 bit as shown in the following screenshot

enter image description here

The problem is that I can not check the Prefer 32 bit because the live project is quite huge and if I check it up then some other issues may occur.

Many thanks for any help.

Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236
Hardik Sachdeva
  • 195
  • 4
  • 12
  • Is the assembly you are trying to load 32 or 64 bit? The error is telling you that you are loading the *wrong* version. Instead of modifying the bitness, reference the proper assembly. SQLite is a native DLL so System.Data.Sqlite comes in two versions (32 and 64 bit), one for the 32-bit and one for the 64-bit version – Panagiotis Kanavos Jan 29 '16 at 12:35
  • How did you add SQLite to the project? Had you used the NuGet package, the proper version would be added. Did you manually add a reference to a downloaded assembly? – Panagiotis Kanavos Jan 29 '16 at 12:38
  • @PanagiotisKanavos my application .net version is 4.5 and SQLite version is also 4.5. I have download the assembly not from nuget. I have manually added the reference of the assembly – Hardik Sachdeva Jan 29 '16 at 12:42
  • That's irrelevant. There are 32-bit and 64-bit versions of SQLite. Obviously you downloaded and referenced the wrong one. Instead of downloading it, use NuGet to install the correct version. There are dozens of similar questions in SO. Check the duplicate question for details on how to either add the NuGet package, or reference the correct assembly. Although all this is already in the System.Data.SQLite docs – Panagiotis Kanavos Jan 29 '16 at 12:44
  • There are 2 sql DLLs 1. System.Data.SQLite.dll and 2nd is SQLite.Interop.dll. `SQLite.Interop.dll` is used depending on the architecture (64/86). I am using 64 bit SQLite.Interop.dll – Hardik Sachdeva Jan 29 '16 at 12:46
  • 1
    Did you read the duplicate question? Did you try to *add the package*? – Panagiotis Kanavos Jan 29 '16 at 12:49

0 Answers0