System.EntryPointNotFoundException on SqlDataAdapter.Fill Method
-
26-10-2019 - |
Question
We are concurrently developing Android and iPhone apps and the core code (written in C#) is shared between them. The SQLite database initialization code, for example, is the same in both apps with only slight variations to accommodate the file structure on each platform. The following code is working in MonoTouch, but throws an EntryPointNotFoundException in Mono for Android:
try
{
System.Data.Common.DbDataAdapter adapter = new SqliteDataAdapter(selectCommand);
retVal = adapter.Fill(dataSet);
}
catch (Exception exception)
{
...
}
As far as I can tell, the selectCommand and dataSet objects are identical on both platforms The message and stack trace are as follows:
> System.EntryPointNotFoundException: sqlite3_column_origin_name at (wrapper managed-to-native) Mono.Data.Sqlite.UnsafeNativeMethods:sqlite3_column_origin_name (intptr,int)
at Mono.Data.Sqlite.SQLite3.ColumnOriginalName (Mono.Data.Sqlite.SqliteStatement stmt, Int32 index) [0x00000] in /home/jon/Development/xamarin/mono/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLite3.cs:493
at Mono.Data.Sqlite.SqliteDataReader.GetSchemaTable (Boolean wantUniqueInfo, Boolean wantDefaultValue) [0x0042d] in /home/jon/Development/xamarin/mono/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteDa>taReader.cs:619
at Mono.Data.Sqlite.SqliteDataReader.GetSchemaTable () [0x00000] in /home/jon/Development/xamarin/mono/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteDataReader.cs:550
at System.Data.Common.DataAdapter.BuildSchema (IDataReader reader, System.Data.DataTable table, SchemaType schemaType, MissingSchemaAction missingSchAction, MissingMappingAction missingMapAction, System.Data.Common.DataTableMappingCollection dtMapping) [0x0003b] in /home/jon/Development/xamarin/mono/mcs/class/System.Data/System.Data.Common/DataAdapter.cs:284
at System.Data.Common.DataAdapter.BuildSchema (IDataReader reader, System.Data.DataTable table, SchemaType schemaType) [0x00000] in /home/jon/Development/xamarin/mono/mcs/class/System.Data/System.Data.Common/DataAdapter.cs:257
at System.Data.Common.DataAdapter.FillTable (System.Data.DataTable dataTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords, System.Int32& counter) [0x00011] in /home/jon/Development/xamarin/mono/mcs/class/System.Data/System.Data.Common/DataAdapter.cs:428
at System.Data.Common.DataAdapter.FillInternal (System.Data.DataSet dataSet, System.String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords) [0x0009b] in /home/jon/Development/xamarin/mono/mcs/class/System.Data/System.Data.Common/DataAdapter.cs:533
at System.Data.Common.DataAdapter.Fill (System.Data.DataSet dataSet, System.String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords) [0x00000] in /home/jon/Development/xamarin/mono/mcs/class/System.Data/System.Data.Common/DataAdapter.cs:589
at System.Data.Common.DbDataAdapter.Fill (System.Data.DataSet dataSet, Int32 startRecord, Int32 maxRecords, System.String srcTable, IDbCommand command, CommandBehavior behavior) [0x0004e] in /home/jon/Development/xamarin/mono/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs:337
at System.Data.Common.DbDataAdapter.Fill (System.Data.DataSet dataSet) [0x00000] in /home/jon/Development/xamarin/mono/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs:265
at Core.Database.ServerCommunicate.FillDataSet (Core.Database.XCommand selectCommand, System.Data.DataSet& dataSet) [0x00013] in /Users/sstream6/sd/110/core/Asm/Db/Database/Server.cs:648
I have verified on both platforms that the database has been created and a connection established. Has anyone else experienced similar problems?
Solution
Unfortunately Android's SQLite library doesn't include support for the sqlite3_column_origin_name() method, so any parts of Mono.Data.Sqlite that depend on it are going to fail. Xamarin has a bug tracked here for modifying the implementation to get around the limitation, but there's no timeframe on it yet as far as I know.