System.Data.SQLite

Login
This project makes use of Eagle, provided by Mistachkin Systems.
Eagle: Secure Software Automation
2013-07-15
18:48 Ticket [9ac9862611] Wrong processor architechture detected in System.Data.SQLite.dll while running out of visual studio status still Closed with 5 other changes artifact: c8a3bff271 user: mistachkin
18:46
Implement a workaround for the issue described in ticket [9ac9862611]. check-in: f54929f54e user: mistachkin tags: trunk
18:21
Implement a workaround for the issue described in ticket [9ac9862611]. Closed-Leaf check-in: dc86717583 user: mistachkin tags: tkt-9ac9862611
09:28 Ticket [9ac9862611] Wrong processor architechture detected in System.Data.SQLite.dll while running out of visual studio status still Closed with 3 other changes artifact: c45cb7d17b user: mistachkin
09:28 Add attachment wrongArch-part2.png to ticket [9ac9862611] artifact: cc81d64031 user: mistachkin
09:28 Add attachment wrongArch-part1.png to ticket [9ac9862611] artifact: 2f1bdd1af5 user: mistachkin
09:23 Ticket [9ac9862611] Wrong processor architechture detected in System.Data.SQLite.dll while running out of visual studio status still Closed with 4 other changes artifact: 0cf5ae2ea7 user: mistachkin
2013-04-18
20:01 Closed ticket [9ac9862611]. artifact: ddb0914073 user: mistachkin
2013-04-10
11:40 Ticket [9ac9862611]: 3 changes artifact: 94ecad286f user: mistachkin
11:29 Ticket [9ac9862611]: 3 changes artifact: fbbbf26364 user: anonymous
11:18 Pending ticket [9ac9862611]. artifact: a8f0b4435c user: mistachkin
08:28 New ticket [9ac9862611]. artifact: 88a7c46a5e user: anonymous

Ticket Hash: 9ac9862611f9e8eaa06fa9024418d6f0e591b967
Title: Wrong processor architechture detected in System.Data.SQLite.dll while running out of visual studio
Status: Closed Type: Incident
Severity: Important Priority: NextRelease
Subsystem: Integration_Via_PInvoke Resolution: Workaround
Last Modified: 2013-07-15 18:48:16
Version Found In: 1.0.84.0
User Comments:
anonymous added on 2013-04-10 08:28:16:
We’re using SQLite in a mixed environment. The host application is written in Delphi and compiled as 32-bit process. This application calls .Net code that uses SQLite.

The .Net assemblies are currently compiled using architecture “AnyCPU”. If I start the main application itself all is working correct. The environment variable “PROCESSOR_ARCHITECTURE“ is set to „x86“.

If I start the same host application out of visual studio running on a x64 OS the variable is set to “AMD64” (in my case) which is not correct for the currently running process.

The method UnsafeNativeMethods.PreLoadSQLiteDll(..) uses this environment variable to determine the architecture and tries to load the needed assembly.

The only thing to do is to check whether the currently running process is a 32-bit or 64-bit process, isn't it?

It would be possible to use the properties “Is64BitOperatingSystem” (true in my case) and “Is64BitProcess” (false in my case). Both are set correct even if visual studio starts the process.

If you’ll use these properties it would be possible to use SQLite out of visual studio having a x86 host application and an “AnyCPU” compiled assembly that references SQLite started on a 64-bit OS.

mistachkin added on 2013-04-10 11:18:34:
First, I've never seen the PROCESSOR_ARCHITECTURE environment variable set to
the wrong value.  Is it possible that some other component in the process is
setting it?

Second, if you are running a pure managed executable assembly on an x64 machine,
the environment variable should indeed be "AMD64".  In that case, you'll want to
make sure that both the x86 and x64 SQLite interop assembly files are available
and are deployed to the correct directories within the application binary
directory.

Since the PROCESSOR_ARCHITECTURE environment variable value itself is used to
help construct the final file name for the SQLite interop assembly, simply using
a binary (yes/no) check for a 64-bit process will not be a drop-in replacement,
nor should it be necessary in this case.

Finally, if the PROCESSOR_ARCHITECTURE environment variable is indeed being set
to the wrong value for the process by the operating system (i.e. due to a bug),
it can be easily overridden by the application prior to loading the
System.Data.SQLite assembly, for example:

    Environment.SetEnvironmentVariable("PROCESSOR_ARCHITECTURE",
        Environment.Is64BitProcess ? "AMD64" : "x86");

However, it should be noted here that assuming a 32-bit process is "x86" (or
that a 64-bit process is "AMD64") may not always be true, due to things like
32-bit ARM, etc.

anonymous added on 2013-04-10 11:29:45:
Please take a look at the following blog entry - it describes exactly my problem:
http://lesscode.net/blog/2011/3/31/processor_architecture-and-visual-studio-debugging.html

mistachkin added on 2013-04-10 11:40:35:
That may be caused by this:

http://stackoverflow.com/questions/6749187/why-does-createenvironmentblock-on-a-wow64-process-give-me-processor-architectur

Or it could just be an issue with Visual Studio.  Either way, my original
comments are still valid.

mistachkin added on 2013-07-15 09:23:22:
I've now seen this issue occur from within Visual Studio 2012 running on a 64-bit
Windows 7 machine.  It appears to require the "Prefer 32-bit" project option to
be enabled.

This appears to be a bug in the operating system and/or Visual Studio.

mistachkin added on 2013-07-15 09:28:59:
Screenshots with proof of issue added.

mistachkin added on 2013-07-15 18:48:16:
Workaround implemented by check-in [f54929f54e] on trunk.  This will be in the
next release, 1.0.88.0.

Attachments: