views:

111

answers:

1

I am using SQLite for the unit testing and might use it as a database for local development/staging.

The System.Data.SQLite has basically 2 versions: x86 and x64. Correct one should be used for the specific platform.

I have 64 bit Win7, other guys in the team might use 32-bit OSs. The server's platform is not known at this stage.

If I use 32-bit version of the assembly on 64-bit platform I get BadImageFormatException: Could not load file or assembly 'System.Data.SQLite'. I believe similar will happen trying to use 64-bit assembly on 32-bit platform.

So my question is what is the best way to reference the SQLite assembly so that it does not depend on the platform and people can just use it?

It is ok to use 32-bit version of assembly on a 64-bit platform (Maybe there is a switch for that somewhere?).

A: 

If it's installed into the GAC, then you just reference the assembly and the system will pick the correct one.

Otherwise, you need to make sure you reference the correct one "manually" (I have, in the past, used a build system that copied the correct version to the "deploy" folder when building. These days, everything I do is 64-bit so it's not such a big deal).

Alternatively, you can build your application as x86 and then just use the 32-bit version exclusively. In the project properties, on the Build tab, set "Platform target" to "x86". You only need to do this with executables: DLLs can still be AnyCPU.

Dean Harding
I have referenced it from GAC but it uses 32-bit version assembly.
Dmytrii Nagirniak
Ok. I will have to accept the answer which sounds like solution. It doesn't work as i expect though. For now I have set the platform to x86 for my projects and use x86 version all the time.
Dmytrii Nagirniak