Sqlite – How to remove the error “Cant find PInvoke DLL SQLite.interop.dll”

sqlitewindows-mobile

I am developing windows mobile application. I am using the SQLlite database. I am using the following code to connect to this database as follows

                SQLiteConnection cn = new SQLiteConnection();
                SQLiteDataReader SQLiteDR;
                cn.ConnectionString = @"Data Source=F:\CompNetDB.db3";
                cn.Open();
                SQLiteCommand cmd = new SQLiteCommand();
                cmd.CommandText = "select * from CustomerInfo";
                cmd.CommandType = CommandType.Text;
                cmd.Connection = cn;
                SQLiteDR = cmd.ExecuteReader();

In the above case I am getting the error "Cant find PInvike DLL SQLite.interop.dll". I have added the DLL System.Data.SQLLite from the \SQLite.NET\bin\compactframework this folder. This is the folder which is installed by default when I installed the SQLite. In the same folder there is one DLL file named SQLlite.Interop.66.DLL. When I try to add reference to this dll it is giving error that dll can not be added. Are the two dlls SQLlite.Interop.dll & System.Interop.066.dll same ? In the above code how to solve the error "Cant find PInvoke.SQLite.Interop.dll" Please can you tell whether there is mistake in my code or I am missing something in my application?

Best Answer

The interop DLL is a C DLL that has entry points for P/Invoke calls made in System.Data.SQLIte. You cannot add a reference to a native DLL, you have to copy it to the device separately. An easy way to do this is to add it to your project, set the build action to 'Content' and set Copy to Output Directory to 'Copy if Newer'. When you debug, Studio will then push that file down to the device for you.

Related Topic