Jerry
Jerry

Reputation: 6557

System.BadImageFormatException with Sqlite

I am trying to use SQLite with my WPF application. I can get the reads and writes to work ok. The only problem I have is that my xaml is not displaying and I get the following error:

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

My questions: -How do I know what version of SQLite that I am using? 32bit or 64bit? -I tried changing the Platform target to x86 and x64 but neither help. How can I resolve this error?

Upvotes: 3

Views: 1897

Answers (2)

Amir Reza
Amir Reza

Reputation: 473

A System.BadImageFormatException error often occurs when a 64-bit assembly is opened by a 32-bit application or Conversely. In this case, Visual Studio is a 32-bit application and the Design view is attempting to load a 64-bit assembly. Visual Studio assemblies are located in the project references tree. Right click on Your Project and select properties item. In Build Tab, change platform target to Any CPU.

Upvotes: 0

Jaded
Jaded

Reputation: 1831

Had same problem when used 64-bit precompiled binaries. Solution is use 32-bit ones instead (manually download them from SQLite site if needed).

Upvotes: 2

Related Questions