I have a .NET 4 app which consists of the app and two class libraries. All use a reference to System.Data.SQLite. I’m using the x86 version of SQLite and all of my assemblies are set to x86.
On some machines, when I try to do something in the app which uses SQLite, I get an unhandled exception:
Could not load file or assembly ‘System.Data.SQLite, Version=1.0.79.0,
Culture=neutral, PublicKeyToken=db937bc2d44ff139’ or one of its
dependencies. An attempt was made to load a program with an incorrect
format.
I’m at my wits end with this, as I’ve tried both the .NET 3.5 and .NET 4 SQLite DLLs in x86 and x64 and I get the same error. I’ve tested on four machines. The following work fine:
- Win7 Ultimate x64
- Win7 Pro x64
- Server 2008 x64
The following throw the exception:
- Win7 Ultimate x64 (user’s machine)
- WinXP inside XP Mode on the Win7
Ultimate x64 which works
If it was an architecture problem, I’d expect XP Mode running on a working Win7 x64 to also work, but it doesn’t. Also, none of the test.exe files includede with the SQLite bundle work inside VMWare, which makes me think there’s something missing.
I’ve run FUSLOGVW on the machine in XP Mode and this is the entry for System.Data.SQLite:
The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.
Assembly manager loaded from: c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Documents and Settings\XPMUser\Desktop\Release\ChickenPing.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = VIRTUALXP-92688\XPMUser
LOG: DisplayName = System.Data.SQLite, Version=1.0.79.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139
(Fully-specified)
LOG: Appbase = file:///C:/Documents and Settings/XPMUser/Desktop/Release/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = ChickenPing.exe
Calling assembly : ChickenPing.DAL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Documents and Settings\XPMUser\Desktop\Release\ChickenPing.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Data.SQLite, Version=1.0.79.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Documents and Settings/XPMUser/Desktop/Release/System.Data.SQLite.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Documents and Settings\XPMUser\Desktop\Release\System.Data.SQLite.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: System.Data.SQLite, Version=1.0.79.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139
LOG: Binding succeeds. Returns assembly from C:\Documents and Settings\XPMUser\Desktop\Release\System.Data.SQLite.dll.
LOG: Assembly is loaded in default load context.
Which indicates success, yet the unhandled exception still occurs?
This was somewhat obscure to track down. It turns out the VC++ 2010 redistributable runtime is needed. As far as I know, System.Data.SQLite never used to have this dependancy, or at least I was never aware of it.