Hello
I have a .net application which I want to port to Mono. The application takes a xml file validates it and "executes" the xml.
The validation part is not working on Mono. The xml is validating against XSD.
XmlReaderSettings settings = new XmlReaderSettings();
settings.ValidationEventHandler += new System.Xml.Schema.ValidationEventHandler(XmlValidationEventHandler);
settings.ValidationType = ValidationType.Schema;
settings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings;
settings.Schemas.Add("http://eltrade.com/" + m_Schema, XmlReader.Create(stream));
stream.Close();
Console.WriteLine("Create xmlValidationReader");
// Validate the XML with XS
using (XmlReader xmlValidationReader = XmlReader.Create(m_document, settings))
{
try
{
Console.WriteLine("Begin xml validation");
while (xmlValidationReader.Read())
{
Console.WriteLine(xmlValidationReader.ReadInnerXml());
Console.WriteLine("---");
}
}
catch (XmlSchemaException SE)
{
m_success = false;
Console.WriteLine("XmlSchemaException: " + SE.Message + " " + SE.SourceSchemaObject.SourceUri);
}
catch (XmlException XE)
{
m_success = false;
Console.WriteLine("XMLException: " + XE.Message + " " + XE.SourceUri);
}
catch (Exception E)
{
m_success = false;
Console.WriteLine("Exception: " + E.Message);
}
}
When I run the validation (the above function), only the first line of the xml is read and exception is thrown: Cannot cast source type to destination type. Unable to cast object of type 'System.UInt32' to type 'System.Int64'.
<bons xmlns="http://eltrade.com/schema-file-driver.xsd">
<receipt id="10">
<type>
<nonfiscal/>
</type>
<prints>
<line>
<text>Free text at the top of receipt.</text>
<wordwrap>true</wordwrap>
</line>
<payments>
<pay1>all</pay1>
</payments>
</prints>
</receipt>
</bons>
On windows with the .Net framework everything is working fine.
With Mono (on Linux and Windows) the validation throws the above exception.
Using Mono v.2.4.2.3 on the Linux (kubuntu) machine and
Mono v.2.6.4 on the Windows machine.
What would be the cause of the exception?
<bons xmlns="http://eltrade.com/schema-file-driver.xsd">
doesn't contains any numeric value to cast it to Int64.