Good afternoon,
An XML schema validation snippet is working fine on development/q&a environments, but is yielding some odd validation results in Production. The usual suspect would be that the code is unsafe for threading, and that the additional load of the Production scenario is flushing out the error.
The exact scenario is as follows. Consider that the XML being validated is:
<mssql:spExecute type="ResultSet" xmlns:mssql="urn:namespace">
<mssql:actor>IPASS</mssql:actor>
<mssql:connection>ConnectionString</mssql:connection>
<mssql:storedProcedure>dbo.RedFox</mssql:storedProcedure>
</mssql:spExecute>
In the course of a full day, around 300 executions (of >2M) will yield the following exception:
System.Xml.Schema.XmlSchemaValidationException The 'http://www.w3.org/2000/xmlns/:mssql' attribute is not declared.
The schema validator seems to complain about the namespace declaration.
The code structure is as follows:
- There is a static instance of XmlSchemaSet;
- Initialization of the XmlSchemaSet instance is being done in a thread-safe manner;
- Each worker thread makes use of the same XmlSchemaSet;
- The validation occurs during an XmlSerializer.Deserialize() call, using an XmlReader with XmlReaderSettings initialized with ValidationType.Schema.
Any thoughts on what might be causing the validation to choke with the namespace declaration?