Problem using System.data.SQLite

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem using System.data.SQLite

Bernd Schuhmacher
Hi

I am trying to put up a little program using System.data.SQLite with C# under Visual Studio 2017. The Target Framework is dotnet core 2.0
I imported the nuget Package (Project - manage nuget Package ...) into the Project.
The compilation works fine. But if running the compiled program I get an error: System.IO.FileNotFoundException: "Could not load file or assembly 'System.Data.SQLite, Version=1.0.109.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139'. Das System kann die angegebene Datei nicht finden."

The used code is very simple:

private string getID(string pfad)
        {
            SQLiteConnection sqlite_conn = new SQLiteConnection("Data Source="+pfad+";Password="+sqlitepwd+";");
            sqlite_conn.Open();
            SQLiteCommand sqlite_cmd = sqlite_conn.CreateCommand();
            sqlite_cmd.CommandText = "SELECT ID FROM IDList";
            string id = (string)sqlite_cmd.ExecuteScalar();
            sqlite_conn.Close();
            return id;
            }
The error message is created when calling the function ...

If I ladd the nuget package "System.Data.SQLite.x64" to the project the code runs up to the line
SQLiteCommand sqlite_cmd = sqlite_conn.CreateCommand();

The exception "System.AccessViolationException: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."" Is triggerd.

There seems to be no Problem when compiling againt .Net Framework 4.6.2. If I understand the Version history correctly  it should work with dotnet core 2, or am I wrong with that?
Does anybody have an idea what's wrong here?

Regards
Bernd

Bernd Schuhmacher
Development Department

CRANIMAX GmbH, Amerikastrasse 14, 66482 Zweibr?cken, Germany

T +49 6332 90 74 125
[hidden email]<mailto:[hidden email]>

Please consider the impact on the environment before printing this e-mail.

Pflichtangaben/Mandatory Disclosure Statements:
http://www.cranimax.com/de/impressum
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem using System.data.SQLite

Joe Mistachkin-3

Schuhmacher, Bernd wrote:

>
> I am trying to put up a little program using System.data.SQLite with C#
> under Visual Studio 2017. The Target Framework is dotnet core 2.0
> I imported the nuget Package (Project - manage nuget Package ...) into
> the Project.
> The compilation works fine. But if running the compiled program I get
> an error: System.IO.FileNotFoundException: "Could not load file or
> assembly 'System.Data.SQLite, Version=1.0.109.0, Culture=neutral,
> PublicKeyToken=db937bc2d44ff139'. Das System kann die angegebene Datei
> nicht finden."
>

The NuGet package "System.Data.SQLite.x64" contains binaries that have
not been tested with .NET Core.  In fact, since it uses the mixed-mode
assembly, I sincerely doubt it can ever work with .NET Core as they do
not support those, e.g.:

        https://github.com/dotnet/coreclr/issues/18013

Instead, the NuGet package "System.Data.SQLite.Core" should be used;
unfortunately, due to assembly deployment issues with .NET Core, it is
not as simple as it could be:

        https://system.data.sqlite.org/index.html/info/67d10c4262d45d26

I'm not quite sure how to address deployment these issues in a portable
(and supported) way.  It appears that I may need to figure out a way to
automatically update the JSON file associated with the application, but
that does not seem like the most elegant solution.

--
Joe Mistachkin

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users