Bug 29968

Summary: Mono.Data.SQlite SourceTable is required to be a non-empty string Parameter name: sourceTable
Product: iOS Reporter: matteo
Component: Xamarin.iOS.dllAssignee: Marek Safar <masafa>
Severity: normal CC: brendan.zagaeski, CoderPersonGuy, fricompte, mono-bugs+monotouch, rolf, shane, udhams
Priority: Normal    
Version: XI 8.10   
Target Milestone: Untriaged   
Hardware: Macintosh   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: Test project

Description matteo 2015-05-12 08:14:49 UTC
After update to Xamarin iOS is impossibile to read SQLite database with Mono.Data.Sqlite

To reproduce the error:

string AppFolder =
            string DBName = AppFolder + "/test.db";
            Mono.Data.Sqlite.SqliteConnection Cnn = new
Mono.Data.Sqlite.SqliteConnection("Data source=" + DBName);
            if (System.IO.File.Exists(DBName) == false)


            Mono.Data.Sqlite.SqliteCommand CreateTableCommand = new
Mono.Data.Sqlite.SqliteCommand("CREATE TABLE IF NOT EXISTS test (field1 int)",

            Mono.Data.Sqlite.SqliteCommand SelectCommand = new
Mono.Data.Sqlite.SqliteCommand("SELECT * FROM Test", Cnn);
            Mono.Data.Sqlite.SqliteDataAdapter Adapter = new

            System.Data.DataTable Data = new System.Data.DataTable();
Comment 1 Rolf Bjarne Kvinge [MSFT] 2015-05-12 09:21:59 UTC
Created attachment 11163 [details]
Test project
Comment 2 Rolf Bjarne Kvinge [MSFT] 2015-05-12 09:22:42 UTC
This looks like a regression in the BCL.

@Marek, can you have a look (or assign more appropriately)?
Comment 3 Marek Safar 2015-05-12 11:45:15 UTC
Could you attach the exception you get
Comment 4 matteo 2015-05-12 11:52:11 UTC
SourceTable is required to be a non-empty string Parameter name: sourceTable
Comment 5 Rolf Bjarne Kvinge [MSFT] 2015-05-12 13:22:25 UTC
Full exception details:

> System.ArgumentException: SourceTable is required to be a non-empty string
> Parameter name: sourceTable
>   at System.Data.Common.DataTableMappingCollection.GetTableMappingBySchemaAction (System.Data.Common.DataTableMappingCollection tableMappings, System.String sourceTable, System.String dataSetTable, MissingMappingAction mappingAction) [0x0002d] in //Library/Frameworks/Xamarin.iOS.framework/Versions/ 
>   at System.Data.Common.DataAdapter.SetupSchema (SchemaType schemaType, System.String sourceTableName) [0x00009] in //Library/Frameworks/Xamarin.iOS.framework/Versions/ 
>   at System.Data.Common.DataAdapter.FillInternal (System.Data.DataTable dataTable, IDataReader dataReader) [0x00015] in //Library/Frameworks/Xamarin.iOS.framework/Versions/ 
>   at System.Data.Common.DataAdapter.Fill (System.Data.DataTable dataTable, IDataReader dataReader) [0x00000] in //Library/Frameworks/Xamarin.iOS.framework/Versions/ 
>   at System.Data.Common.DbDataAdapter.Fill (System.Data.DataTable dataTable, IDbCommand command, CommandBehavior behavior) [0x00022] in //Library/Frameworks/Xamarin.iOS.framework/Versions/ 
>   at System.Data.Common.DbDataAdapter.Fill (System.Data.DataTable dataTable) [0x00011] in //Library/Frameworks/Xamarin.iOS.framework/Versions/ 
>   at AppDelegate.MiscTapped () [0x00081] in /Users/rolf/Downloads/bug29968/AppDelegate.cs:129 
>   at AppDelegate.<FinishedLaunching>m__1 (MonoTouch.Dialog.GlassButton obj) [0x00003] in /Users/rolf/Downloads/bug29968/AppDelegate.cs:90
Comment 6 matteo 2015-05-13 03:42:47 UTC
The problem appears to be that the new imported Microsoft Reference Source for System.Data.Common.DataTableMappingCollection.GetTableMappingBySchemaAction() enforces an additional requirement that the DataTable passed into Adapter.Fill() must have the DataTable.TableName property set to a non-empty string.
Comment 7 Marek Safar 2015-05-14 11:15:59 UTC
Already fixed in mono master (complete System.Data import)
Comment 8 Shane van Wyk 2015-06-10 18:10:01 UTC
On which version of mono is it fixed? We are sitting on and it is broken. Also when will it go out to the Repos so that it can be updated via Ubuntu package upgrade?
Comment 9 Sylvain 2015-07-03 07:46:50 UTC
Very sadely, does not fix it either. Any ETA for the release of a package that contains the fix mentionned Comment 7?
Comment 10 CoderPersonGuy 2015-07-07 18:19:11 UTC
i'm hitting this also on  any word on when this fix will be released?  is there an easy way to switch to an old version or "beta" that includes it?
Comment 11 CoderPersonGuy 2015-07-07 18:44:07 UTC
I tried to install 3.12.0 to no avail -- apt-get did not like repositories with / in the name.  Seems to be a known issue.

So I install the nightly.  I now get a different crash:

Exception: NullReferenceException: Object reference not set to an instance of an object
  at System.Data.SqlClient.SqlDataReader.GetValues (System.Object[] values) <0x40984000 + 0x0006d> in <filename unknown>:0 
  at System.Data.ProviderBase.DataReaderContainer+CommonLanguageSubsetDataReader.GetValues (System.Object[] values) <0x40983f90 + 0x00029> in <filename unknown>:0 
  at System.Data.ProviderBase.SchemaMapping.LoadDataRow () <0x40983d90 + 0x00030> in <filename unknown>:0 
  at System.Data.Common.DataAdapter.FillLoadDataRow (System.Data.ProviderBase.SchemaMapping mapping) <0x40983910 + 0x00137> in <filename unknown>:0 
  at System.Data.Common.DataAdapter.FillFromReader (System.Data.DataSet dataset, System.Data.DataTable datatable, System.String srcTable, System.Data.ProviderBase.DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, System.Data.DataColumn parentChapterColumn, System.Object parentChapterValue) <0x4097d300 + 0x0011b> in <filename unknown>:0 
  at System.Data.Common.DataAdapter.Fill (System.Data.DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords) <0x4097c920 + 0x00287> in <filename unknown>:0 
  at System.Data.Common.DbDataAdapter.FillInternal (System.Data.DataSet dataset, System.Data.DataTable[] datatables, Int32 startRecord, Int32 maxRecords, System.String srcTable, IDbCommand command, CommandBehavior behavior) <0x4097bcb0 + 0x0011c> in <filename unknown>:0 
  at System.Data.Common.DbDataAdapter.Fill (System.Data.DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) <0x4097b9f0 + 0x00173> in <filename unknown>:0 
  at System.Data.Common.DbDataAdapter.Fill (System.Data.DataTable dataTable) <0x4097b740 + 0x000c2> in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Data.Common.DbDataAdapter:Fill (System.Data.DataTable)
Comment 12 Brendan Zagaeski (Xamarin Team, assistant) 2015-11-13 22:41:34 UTC
The problem from the nightly in Comment 11 seems to require different conditions to reproduce. I was able to reproduce it with a different test case, and I have accordingly filed a bug for it here:

Bug 35857

(Side note: to a first approximation, a new bug report will be needed any time the unhandled exception that's causing a crash changes.)

Xamarin Customer Support