title: Running Sqlite on Mono
body: <p>I am working on a c# project which makes use of an SQLite3 database and needs to be cross compatible between windows and linux.</p>
  <p>The linux server is using version 3.2.8 and I am using the Managed Sqlite Library DLL 1.0.66.0.</p>
  <p>I have copied the DLL to the server and when I run mono myexec.exe it displays the following error</p>
  <blockquote>
  <p>Unhandled Exception: System.EntryPointNotFoundException:
  sqlite3_open_v2   at (wrapper managed-to-native)
  System.Data.SQLite.UnsafeNativeMethods:sqlite3_open_v2
  (byte[],intptr&amp;,int,intptr)   at System.Data.SQLite.SQLite3.Open
  (System.String strFilename, SQLiteOpenFlagsEnum flags, Int32
  maxPoolSize, Boolean usePool) [0x00000] in :0   at
  System.Data.SQLite.SQLiteConnection.Open () [0x00000] in :0   at AudioManagement.DatabaseConnection..ctor () [0x00000]
  in :0   at
  LinuxAudioManager.Configure.startConfiguration () [0x00000] in
  :0   at LinuxAudioManager.Program.Main
  (System.String[] args) [0x00000] in :0</p>
  </blockquote>
  <p>This error is thrown when it attempts to either make the database file or open the connection, I am not sure which one it is.</p>
  <p>Below is the code I am using in order create the connection</p>
  <pre><code>conn = new SQLiteConnection(&quot;Data Source=database.db&quot;);
  conn.Open()
  </code></pre>
  <p>Thanks for any help you can provide.</p>
  <p><strong>UPDATE</strong>
  I have just executed my program with the mono logging and found something rather strange. Its seems to have a problem loading the lib file. The output is below</p>
  <blockquote>
  <p>Mono-INFO: DllImport attempting to load: 'libsqlite3.so.0'. Mono-INFO:</p>
  <p>DllImport loading location: 'libsqlite3.so.0.so'. Mono-INFO: DllImport</p>
  <p>error loading library: 'libsqlite3.so.0.so: cannot open shared object</p>
  <p>file: No such file or directory'. Mono-INFO: DllImport loading</p>
  <p>library: './libsqlite3.so.0.so'. Mono-INFO: DllImport error loading</p>
  <p>library './libsqlite3.so.0.so: cannot open shared object file: No such</p>
  <p>file or directory'. Mono-INFO: DllImport loading: 'libsqlite3.so.0'.</p>
  <p>Mono-INFO: Searching for 'sqlite3_open_v2'. Mono-INFO: Probing</p>
  <p>'sqlite3_open_v2'. Mono-INFO: Probing 'sqlite3_open_v2'. Mono-INFO:</p>
  <p>Probing 'sqlite3_open_v2A'. Mono-INFO: Probing 'sqlite3_open_v2A'.</p>
  <p>Mono-INFO: DllImport attempting to load: 'libsqlite3.so.0'. Mono-INFO:</p>
  <p>DllImport loading location: 'libsqlite3.so.0.so'. Mono-INFO: DllImport</p>
  <p>error loading library: 'libsqlite3.so.0.so: cannot open shared object</p>
  <p>file: No such file or directory'. Mono-INFO: DllImport loading</p>
  <p>library: './libsqlite3.so.0.so'. Mono-INFO: DllImport error loading</p>
  <p>library './libsqlite3.so.0.so: cannot open shared object file: No such</p>
  <p>file or directory'. Mono-INFO: DllImport loading: 'libsqlite3.so.0'.</p>
  <p>Mono-INFO: Searching for 'sqlite3_open_v2'. Mono-INFO: Probing</p>
  <p>'sqlite3_open_v2'. Mono-INFO: Probing 'sqlite3_open_v2'. Mono-INFO:</p>
  <p>Probing 'sqlite3_open_v2A'. Mono-INFO: Probing 'sqlite3_open_v2A'.</p>
  </blockquote>
  <p>The file libsqlite3.so.0 does exist but I can't see why mono is then attempting to load
  libsqlite3.so.0.so.</p>
  <p><strong>UPDATE 2</strong>
  I think the first update error messages were pointing me in the wrong direction as I have created a symlink to match where it couldn't find the lib file and mono is no longer saying that it couldn't load something. However the original EntryPointNotFoundException is still displayed</p>
  <p><strong>UPDATE 3</strong>
  Thanks to @bryanmac I have changed the code to use the Mono.Data.Sqlite dll instead which works fine on Linux under mono. However, using this DLL in Windows is now no longer working. VS2010 will build it without problems but when I try to execute it it will display the error</p>
  <blockquote>
  <p>Unable to load DLL 'sqlite3': The specified module could not be found</p>
  </blockquote>
  <p>I have downloaded an sqlite3.exe binary from the sqlite website and the executable to the executable of my program but my program still displays the error message on Windows.</p>