Our project uses Xml and Xml Schema to perform quick configuration changes within our application.
We are building it as a Windows Standalone application and as a Web Player application.
This problem only occurs when running the Web Player version:
I am specifying an xml file and a schema file as text assets in the inspector.
I have an XMLReader object that prepares XmlReaderSettings.
When it tries to read the schema, it throws a TypeInitializationException.
This appears to be caused by a private or protected permission that only exists in the Web Player build.
Is my understanding of the problem correct?
Will there be a fix for this issue?
===============================================================
Here’s the code excerpt. schemaA and xmlA are passed in as TextAsset:
using System.Xml.Schema;
...
System.IO.MemoryStream schemaStreamL = new System.IO.MemoryStream(schemaA.bytes);
System.IO.MemoryStream xmlStreamL = new System.IO.MemoryStream(xmlA.bytes);
ValidationEventHandler handlerL = new ValidationEventHandler(ValidationHandler);
// Validation Settings
XmlReaderSettings settingsL = new XmlReaderSettings();
settingsL.CloseInput = true;
settingsL.IgnoreComments = true;
settingsL.ValidationType = ValidationType.Schema;
settingsL.ValidationEventHandler += handlerL;
settingsL.ValidationFlags |=
XmlSchemaValidationFlags.ReportValidationWarnings |
XmlSchemaValidationFlags.ProcessIdentityConstraints;
// Read Schema
Debug.Log("Create Schema reader");
XmlSchema xmlschemaL = XmlSchema.Read(schemaStreamL, handlerL);
Debug.Log("Add Schema to settings");
settingsL.Schemas.Add(xmlschemaL);
// Load XML
Debug.Log("Loading XML into XmlDOC");
m_Document.Load(XmlReader.Create(xmlStreamL, settingsL));
===============================================================
Log Generated by the Web Player:
…
Create Schema reader
(Filename: C:/BuildAgent/work/14194e8ce88cdf47/Runtime/ExportGenerated/WebPlayer/UnityEngineDebug.cpp Line: 43)
Processing System Exception
(Filename: C:/BuildAgent/work/14194e8ce88cdf47/Runtime/ExportGenerated/WebPlayer/UnityEngineDebug.cpp Line: 43)
System.TypeInitializationException: An exception was thrown by the type initializer for System.Xml.Schema.XmlSchemaUtil —> System.MethodAccessException: Attempt to access a private/protected method failed.
at System.Security.SecurityManager.ThrowException (System.Exception ex) [0x00000] in :0
at System.Xml.Schema.XmlSchemaUtil…cctor () [0x00000] in :0
— End of inner exception stack trace —
at System.Xml.Schema.XmlSchema.ReadAttributes (System.Xml.Schema.XmlSchema schema, System.Xml.Schema.XmlSchemaReader reader, System.Xml.Schema.ValidationEventHandler h) [0x00000] in :0
at System.Xml.Schema.XmlSchema.Read (System.Xml.XmlReader rdr, System.Xml.Schema.ValidationEventHandler validationEventHandler) [0x00000] in :0
at System.Xml.Schema.XmlSchema.Read (System.IO.Stream stream, System.Xml.Schema.ValidationEventHandler validationEventHandler) [0x00000] in :0
at Config.VIC_XMLReader…ctor (UnityEngine.TextAsset xmlA, UnityEngine.TextAsset schemaA, .VIC_ConfigManager vcm) [0x00000] in :0
(Filename: C:/BuildAgent/work/14194e8ce88cdf47/Runtime/ExportGenerated/WebPlayer/UnityEngineDebug.cpp Line: 43)
…