0

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?

Community
  • 1
  • 1
  • Are you asking if the Mono.Data.Sqlite provider is binary compatible with [Microsoft's] .NET? What are you using to code? Visual C# Express? What version of .NET? – ruffin Jul 13 '12 at 18:50
  • @ruffin Visual studios ultimate via the VS2012beta (perhaps express or pro when it expires). Using 3.5 –  Jul 13 '12 at 19:25
  • I really think you are better off compiling it on windows, download the mono sources and look in the mcs/class/ folder. You'll need the sqlite C library too – IanNorton Jul 14 '12 at 05:25

2 Answers2

0

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

Simon MᶜKenzie
  • 8,344
  • 13
  • 50
  • 77
0

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

cthemudo
  • 381
  • 4
  • 5