System.Data.SQLite not found on PC without development

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

The program works fine on the development machine, but when I try to run it on another system, an error always occurs stating that System.Data.SQLite.dll cannot be found. I put the file in the program directory. I also tried putting it in the directory specified in the PATH section. Any suggestions?

I am using openFileDialog to open a database. Here's the corresponding 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 a development machine (Windows 7, 64 bit). The test machine runs in a virtual box (Windows 7, 32 bit). 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. ---------------------------------------- 

Thus, basically it says: "System.Data.SQLite.dll" or the dependency was not found.

The file is present in the application directory. Here is the list of files: File listing

+4
source share
6 answers

If you reference the DLL stored in System.Data.SQLite.dll stored in the GAC on your development machine from your C # project and that the DLL does not exist on the test client, you will receive this message. In this case, you either need to install SQLlite on the test computer (thereby placing the DLL in the GAC), or change the link in your project to indicate the local DLL.

+5
source
  • try referencing a version outside gac
  • Did you specify the correct version (e.g. 32 vs 64 bit)?

I also had this problem, and I think the first point fixed this. The machine on which you deploy it does not have this in gac, and if you refer to this version, it will not be found elsewhere. At least the experience that I had.

+2
source

You need to provide us with more information about the exception. At the same time, try adding the following to your app.config:

 <system.data> <DbProviderFactories> <remove invariant="System.Data.SQLite"/> <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite"/> </DbProviderFactories> </system.data> 
+2
source

I have the same problem. Here's what I did and found: I connected to the AppDomain AssemblyLoad event and traced all the loaded assemblies. I added a class reference to System.Data.SQLite.dll to force it to load before it was used by Fluent NHibernate. And so, SQLite was downloaded from the GAC. I don’t know how this happened because I just downloaded the .Net provider .zip file.

That is why the System.Data.SQLite.dll file is copied locally in the project (Project A), which directly refers to it, but not in projects that refer to project A. Copying is not required for them, since the file is located in the PAC. In my specific case, NHibernate.Driver.SQLite20Driver will try to load the System.Data.SQLite assembly, but for some reason it did not. Perhaps he really expects the assembly to be placed in the output folder, but again I see AssemblyResolve trying for this DLL, which should mean that standard .NET methods are used to load the assembly.

In any case, the solution was to enable and intercept this AssemblyResolve handler in my data access DLL:

 Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { if (args.Name == "System.Data.SQLite") return typeof (CollationSequence).Assembly; else return null; } 

Hope this helps, Christoph

+2
source

For people installing the ADO.NET SQLite Provider on the client computer, it’s not a choice: Download the Microsoft Visual C ++ 2010 Redistributable Package (x64) for 64-bit Windows and Redistributable Package (x64) for 64-bit windows and Install them on client computers. This solved the problem for me.

+2
source

You can use DEPENDS.EXE to find the DLLs that will be accounted for in your System.Data.SQLite.dll library.

In my case, System.Data.SQLite.dll did not want to load without msvcr100.dll (C Runtime Library for native code). Adding it to the application directory solved the problem.

Note: C The runtime library is platform dependent!

+2
source

Source: https://habr.com/ru/post/1341728/


All Articles