Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Data.SQLite not found on non-development PC

I created a C# Project in Visual Studio and used an assembly on the SQLite 4.0 ADO Library from http://sqlite.phxsoftware.com/.

The program runs fine on the development machine, but when I try to run it on another system, there always occurs an error, stating that System.Data.SQLite.dll cannot be found. I placed the file into the program directory. I also tried to put it into a directory that is listed under PATH. Any suggestions?

I'm using an openFileDialog to open the database. Here's the according code:

con = new SQLiteConnection();


                OpenFileDialog ofd1 = new OpenFileDialog();

                ofd1.Filter = "db Datei (*.db)|*.db|Alle Dateien (*.*)|*.*";

                if (ofd1.ShowDialog() == DialogResult.OK)
                    filepath = ofd1.FileName;
                filepath.Replace("\\", "\\\\");
                con.ConnectionString = "Data Source= \"" + filepath + "\"";
    [...]

As already mentioned, this works on the development machine (Windows 7, 64bit). The test machine runs in a virtualbox (Windows 7, 32bit). The following exception occurs:

    System.IO.FileNotFoundException: Die Datei oder Assembly "System.Data.SQLite.dll" oder eine Abhängigkeit davon wurde nicht gefunden. Das angegebene Modul wurde nicht gefunden.
    Dateiname: "System.Data.SQLite.dll"
       bei WindowsFormsApplication1.Form1.button2_Click(Object sender, EventArgs e)
       bei System.Windows.Forms.Control.OnClick(EventArgs e)
       bei System.Windows.Forms.Button.OnClick(EventArgs e)
       bei System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       bei System.Windows.Forms.Control.WndProc(Message& m)
       bei System.Windows.Forms.ButtonBase.WndProc(Message& m)
       bei System.Windows.Forms.Button.WndProc(Message& m)
       bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Geladene Assemblys **************
mscorlib
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.1 (RTMRel.030319-0100).
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll.
----------------------------------------
WindowsFormsApplication1
    Assembly-Version: 1.0.0.0.
    Win32-Version: 1.0.0.0.
    CodeBase: file:///C:/Users/andi/Documents/My%20Dropbox/Own%20Public%20Folders/Public%20(Andy%20Malessa)/juralookup(Wir%20brauchen%20dringend%20nen%20Namen)/DataManagementTool/WindowsFormsApplication1.exe.
----------------------------------------
System.Windows.Forms
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.1 built by: RTMRel.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll.
----------------------------------------
System.Drawing
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.1 built by: RTMRel.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll.
----------------------------------------
System
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.1 built by: RTMRel.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll.
----------------------------------------
System.Windows.Forms.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.1 built by: RTMRel.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_de_b77a5c561934e089/System.Windows.Forms.resources.dll.
----------------------------------------
mscorlib.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.1 (RTMRel.030319-0100).
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_de_b77a5c561934e089/mscorlib.resources.dll.
----------------------------------------

So basically it says: "System.Data.SQLite.dll" or a dependency was not found.

The file is present in the application directory. Here's a file listing: File Listing

like image 551
AndiH Avatar asked Dec 06 '22 23:12

AndiH


2 Answers

If you are referencing the DLL stored in System.Data.SQLite.dll stored in the GAC on your development machine from your C# project and that DLL does not exist on the test client you would get that message. In that case you either need to install SQLlite on the test machine (thereby placing the DLL in the GAC), or change the reference in your project to point at the local DLL instaid.

like image 57
Sean Hunter Avatar answered Dec 29 '22 01:12

Sean Hunter


  1. try referencing a version outside the gac
  2. did you provide the right version (ie. 32 vs 64 bit)?

I had this problem as well and I think the first point fixed it. The machine you deploy it on doesn't have it in the gac obviously, and if you reference that version, it won't be found in the other places. At least that's the experience I had.

like image 24
Femaref Avatar answered Dec 28 '22 23:12

Femaref