none
Mismatch between the processor architecture error with SQLite

    Question

  • I am using Visual Studio 2010, and SQLite. I think the version of sqlite is 3.8.2. The version I think I am using for the System.Data.SQLite.dll (this is the .NET dll, I believe) is 1.0.89.0. Whenever I compile I get this warning:

    Warning 1 There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "System.Data.SQLite, Version=1.0.89.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. PrayerRequestLib

    Now, I am on a Windows 7 x64 box here. My project structure is:

    PrayerRequestLib - all the db code for SQLite is here

    PrayerRequests - this is the main app (desktop app in this case)

    At first I used nuget to install SQLite in my project - Install-Package System.Data.SQLite

    I have gone to the Configuration Manager and have tried to change the projects' platform to match x86. Well, I have tried everything and the PrayerRequestLib platform you get a choice of Any CPU or new or edit. I then downloaded the sqlite dlls for .NET directly from SQLite. I installed them on my pc and directed the references to them. None of these efforts made the above warning go away. What do I need to do and should I worry about this. Finally, the platforms that this program will be installed on will likely be x86 and NOT x64. One more thing, I am using C# for the language. Thanks 

    Ed Cohen


    Edgar Cohen

    Wednesday, January 1, 2014 9:56 PM

Answers

  • Hi Edgar,

    As Anton in this thread said:

    System.Data.SQLite.dll

    is a mixed assembly, i.e. it contains both managed code and native code. Therefore a particular System.Data.SQLite.dll is either x86 or x64, but never both.

    You need to choose an appropriate version of SQLite to install on your machine. For example, my machine is Windows 7 Enterprise 64-bit, I installed Visual Studio 2010 on it. So I choose sqlite-netFx40-setup-bundle-x64-2010-1.0.90.0.exe from SQLite release site. After I installed it and added reference to System.Data.SQLite.dll under the installation folder, I built my project and the warning came up. I checked the target platform of the project and found that the default platform target is "X86", so I changed it to "X64". Finally it worked fine.

    And here is the whole code snippet:

    private string dataSource = "ContactBookDB.sqlite";
            private void button1_Click(object sender, EventArgs e)
            {
                SQLiteConnection.CreateFile(dataSource);
                button1.Text = "DatabaseCreated!";
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                SQLiteConnection dbConn = new SQLiteConnection("Data Source=" + dataSource);
                dbConn.Open();
                SQLiteCommand dbCmd = dbConn.CreateCommand();
                dbCmd.CommandText = "CREATE TABLE TelephoneBook(personID varchar(20),telephone varchar(30),type varchar(20))";
                dbCmd.ExecuteNonQuery();
                dbCmd.CommandText = "INSERT INTO TelephoneBook VALUES('MTB','1234567890','not mobile')";
                dbCmd.ExecuteNonQuery();
                dbCmd.CommandText = "SELECT * FROM TelephoneBook";
                SQLiteDataReader dataReader = dbCmd.ExecuteReader();
                DataTable dataTable = new DataTable();
                if (dataReader.HasRows)
                {
                    dataTable.Load(dataReader);
                }
                dataGridView1.DataSource = dataTable;
                dataReader.Close();
                dbConn.Close();
                button2.Text = "TableCreated!";
            }


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 2, 2014 11:34 AM
    Moderator