Alex Rivera | Logout

Loading x86 or x64 assembly

Asked 2010-09-24T13:16:06.137
13

I have two versions of System.Data.SQLite.DLL - for x86 and x64 platform. The x86 version keeps in application folder and x64 version keeps in appFolder\x64 folder. The application compiled as AnyCPU. How can i load needed version of SQLite according to windows platform?

Edit
Report

2 Answers

5

There is built-in support for this in 1.0.80.0 and later.

If the development and customer machines may have different processor architectures, more than one binary package may be required. For this situation, using the native library pre-loading feature is highly recommended. It is available as of version 1.0.80.0 and enabled by default. (from download page)

However, to get it to work in my own plug-in I also had to add this before referencing SQLite for the first time:

// Make SQLite work... (loading dll from e.g. x64/SQLite.Interop.dll)
System.Environment.SetEnvironmentVariable("PreLoadSQLite_BaseDirectory", System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));

Sql.Data.SQLite...

See this question: New SQLite mixed assemblies

answered 2012-10-24T09:00:17.907
0
  1. install appropriate DLL in the GAC (e.g. 64bit version on a 64bit platform)
  2. use assembly binding in your web/app configuration (possibly in machine config)
  3. Fully qualify any partial assembly references in your web/app config.
answered 2011-10-28T01:21:45.657

Your Answer