Bug 152 - TypeInitializationException using the Mono.Data.Sqlite in a Visual Studio C# (.net4) project
Summary: TypeInitializationException using the Mono.Data.Sqlite in a Visual Studio C# ...
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: Mono.Data.Sqlite ()
Version: 2.10.x
Hardware: PC Windows
: Low normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-08-02 17:57 UTC by Kay Ackermann
Modified: 2015-05-18 05:47 UTC (History)
3 users (show)

Tags: sqlite, .net 4, TypeInitializationException, SqliteConvert
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 152 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description Kay Ackermann 2011-08-02 17:57:02 UTC
The following example throws an exception on Connection.Open()

namespace Monotest {
    class DB {
        SqliteConnection Connection;
        SqliteTransaction TransactionLock;
        public DB() {
            string connectionString = @"URI=file:test.db";
            Connection = new SqliteConnection(connectionString);
            Connection.Open();
        }
    }
}

This only happens with the following constellation in the visual studio project:
used dll: Mono-2.10.2\lib\mono\4.0\Mono.Data.Sqlite.dll
used .net version: 4.0 (client and non-client version)

and it works if the project is using the following constellation:
used dll: Mono-2.10.2\lib\mono\2.0\Mono.Data.Sqlite.dll
used .net version: 3.5 (client and non-client version)


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 Monotest.DB..ctor() in G:\Entwicklung und Programmierung (eigenes!)\Monotest\Monotest\DB.cs:line 14
       at Monotest.Program.Main(String[] args) in G:\Entwicklung und Programmierung (eigenes!)\Monotest\Monotest\Program.cs:line 9
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  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:
Comment 1 Miguel de Icaza [MSFT] 2012-01-03 15:38:46 UTC
Please provide a self-contained test case that shows both scenarios.