The problem:
I'm building a c# 4.0, MVC 3 based web app. I'm using SQLite as a database.
When I start the app, I get this error:
Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. An attempt was made to load a program with an incorrect format.
This is the fusion assembly load trace:
=== Pre-bind state information ===
LOG: User = Steve-PC\Steve
LOG: DisplayName = System.Data.SQLite
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: System.Data.SQLite | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Users/Steve/Documents/Visual Studio 2010/Projects/EMMA3/EMMA_Web/
LOG: Initial PrivatePath = C:\Users\Steve\Documents\Visual Studio 2010\Projects\EMMA3\EMMA_Web\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Steve\Documents\Visual Studio 2010\Projects\EMMA3\EMMA_Web\web.config
LOG: Using host configuration file: C:\Users\Steve\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/Steve/AppData/Local/Temp/Temporary ASP.NET Files/root/6454c2d1/d37faccb/System.Data.SQLite.DLL.
LOG: Attempting download of new URL file:///C:/Users/Steve/AppData/Local/Temp/Temporary ASP.NET Files/root/6454c2d1/d37faccb/System.Data.SQLite/System.Data.SQLite.DLL.
LOG: Attempting download of new URL file:///C:/Users/Steve/Documents/Visual Studio 2010/Projects/EMMA3/EMMA_Web/bin/System.Data.SQLite.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
I am using:
Windows 7 x64 Visual Web Developer 2010 IIS Express 7.5 System.Data.SQLite x64 1.0.77.0
I've Googled around a lot and the general thought seems to be that this is related to running a 32 bit assembly on a 64 bit system or vice versa.
Things I've tried:
Steps to reproduce:
So in summary - I'm getting the error above, it's definitely due in some way to SQLite, I seem to have everything 64 bit, but it still doesn't work. Any ideas?
Thanks in advance.
Figured this out some time ago and forgot about this question.
The answer was to remove SQLite x64 and install SQLite x86... Simple as that. Seems weird when I'm building a 64 bit assembly on a 64 bit version of windows but there we go. The class libraries that actually have the data access logic still reference the 64 bit version of SQLite but for some reason the actual web project has to reference the 32 bit version.