I had to switch from .net 4.5 to .net 4.0 because some of my customers still use WinXP. Now, after switching, this is the error I'm getting:
Could not load file or assembly 'System.Data.SQLite,
Version=1.0.66.0, Culturre-neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies.
An attempt was made to load a program with an incorrect format.
I haven't been able to find a solution for this, but here's what I tried so far:
- Switch back to 4.5 - Didn't work
- Add the reference again - Didn't work
Anyone know a solution?
The right way to fix this is to download an updated version of the SQLite library for your target framework from http://system.data.sqlite.org.
The older System.Data.SQLite assembly that you are using is a mixed code assembly that targets .NET 2.0. The default policy under .NET 4 is to not allow such assemblies to load, but you can explicitly allow it for a process by adding something like this into the MyApp.exe.config file:
<?xml version="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
</startup>
</configuration>
Note that the change can break other things though.
This StackOverflow question covers similar ground: