mono sqlite w/o mono on windows?

2019-09-09 12:29发布

问题:

Once upon a time i asked if there was a way to use a sqlite db on windows/linux w/o two binaries. Someone suggested using mono and i asked if .NET on windows requires a mono install and was told no.

I grabbed this reference file from my linux vm

mono\gac\Mono.Data.Sqlite\2.0.0.0__0738eb9f132ed756\Mono.Data.Sqlite.dll

Then i wrote these two lines in my main()

var connection = new Mono.Data.Sqlite.SqliteConnection("Data Source=test.db3");
connection.Open();

I get this exception

System.TypeInitializationException was unhandled
  Message=The type initializer for 'Mono.Data.Sqlite.SqliteConvert' threw an exception.
  Source=Mono.Data.Sqlite
  TypeName=Mono.Data.Sqlite.SqliteConvert
  StackTrace:
       at Mono.Data.Sqlite.SqliteConvert.Split(String source, Char separator)
       at Mono.Data.Sqlite.SqliteConnection.ParseConnectionString(String connectionString)
       at Mono.Data.Sqlite.SqliteConnection.Open()
       at rsa_test.Program.Main(String[] args) in Program.cs:line 56
  InnerException: System.ArgumentException
       Message=Value does not fall within the expected range.
       Source=mscorlib
       StackTrace:
            at System.Runtime.CompilerServices.RuntimeHelpers.InitializeArray(Array array, RuntimeFieldHandle fldHandle)
            at Mono.Data.Sqlite.SqliteConvert..cctor()
       InnerException: 

So is it not possible to use mono sqlite w/o mono being installed? or did i do something wrong?

回答1:

I met the same problem and discovered that dotConnect for SQLite is another solution which is also compatible with Mono and Windows.



回答2:

You can not use .NET 4.0, you have use .NET 3.5

There is a bug: https://bugzilla.xamarin.com/show_bug.cgi?format=multiple&id=152