Bug 29852 - Error using DataSet.XmlRead
Summary: Error using DataSet.XmlRead
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.XML ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-05-07 14:23 UTC by Rodolfo Redolfi
Modified: 2015-05-18 04:01 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
ZIp containing a sample of the files I'm trying to load (3.05 KB, application/zip)
2015-05-07 14:23 UTC, Rodolfo Redolfi
Details
Zip containing two samples of the same data (1.36 KB, application/zip)
2015-05-08 04:49 UTC, Rodolfo Redolfi
Details


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 on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Rodolfo Redolfi 2015-05-07 14:23:08 UTC
Description of Problem:
Hi, I've create a simple application tha try to load data from xml file containing DataTable's structure and the relative data (at this moment the data are not present). The function crashes with an exception that says "minLength greater than maxLength". The xml file has been created through the corresponding DataSet.WriteXml(xml_file_name,XmlWriteMode.WriteSchema), and it contains the schema of 48 tables. Trying to isolate the issue, I've broken down the whole xml file into single table's xml files. I can load correctly only the first file; starting from the second I experience the same exception.

Steps to reproduce the problem:
1. 
private void PopulateHandler(object sender, EventArgs e)
{
    string[] xmlFiles = Directory.GetFiles(dbPath, "*.xml");
    int h = 0;

    while (h < xmlFiles.Length)
    {
	try
	{
	   DataSet ds = new DataSet();

           ds.ReadXml(xmlFiles[h], XmlReadMode.Auto);
	}
	catch (Exception xmlEx)
	{
	    AlertDialog dlg1 = new AlertDialog.Builder(this).Create();

	    dlg1.SetTitle("ERRORE");
	    dlg1.SetMessage("Errore nel caricamento del file XML " + xmlFiles[h] + System.Environment.NewLine + xmlEx.Message);
	    dlg1.SetButton("CHIUDI", DismissDialogHandler);
	    dlg1.Show();

	    return;
	}

	h++;
    }
2. 


Actual Results:

An exception as I try to load the second file.

Expected Results:


How often does this happen? 

Always

Additional Information:

I've included only the relevant code snippet, the whole application doesn't do anything.
I've also attached the first five xml files.
I know it's not relevant, but the whole xml file is loaded correctly through the same methods under Windows.
Comment 1 Rodolfo Redolfi 2015-05-07 14:23:59 UTC
Created attachment 11123 [details]
ZIp containing a sample of the files I'm trying to load
Comment 2 Rodolfo Redolfi 2015-05-08 03:22:10 UTC
Sorry for the erroneous indication.
The first file actually doesn't contain the schema of a table, as the remaining 47, so the loading error occurs when the DataSet ecounters a table described in the file. The exception generated says that minLength is greater than maxLength, but minLength doesn't appear in the files. My impression is that Xamarin's System.Data.DataSet implementation is slightly different from Microsoft's System.Data.DataSet, so for the moment I'll try to find another solution.
Comment 3 Rodolfo Redolfi 2015-05-08 04:49:08 UTC
Created attachment 11126 [details]
Zip containing two samples of the same data

odbc_AddWithKey is the file created with the corresponding option if the DataAdapter, odbc_NoAddWithKey is created without the option.
Comment 4 Rodolfo Redolfi 2015-05-08 04:51:20 UTC
Further infos...
It turned out that the xml created with a DataSet populated with a DataAdapter with the option DataSet.MissingSchemaAction = MissingSchemaAction.AddWithKey; generates a structure that causes the error in Xamarin. I've attached two samples of the same set of data exported with and without this option.
Comment 5 Marek Safar 2015-05-18 04:01:42 UTC
I cannot reproduce the issue it works for me with 3.12,4.0,master