title: Schema validation error / Thread safety of XmlSchemaSet?
body: <p>Good afternoon,</p>
  
  <p>An XML schema validation snippet is working fine on development/q&amp;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.</p>
  
  <p>The exact scenario is as follows. Consider that the XML being validated is:</p>
  
  <pre><code>&lt;mssql:spExecute type="ResultSet" xmlns:mssql="urn:namespace"&gt;
      &lt;mssql:actor&gt;IPASS&lt;/mssql:actor&gt;
      &lt;mssql:connection&gt;ConnectionString&lt;/mssql:connection&gt;
      &lt;mssql:storedProcedure&gt;dbo.RedFox&lt;/mssql:storedProcedure&gt;
  &lt;/mssql:spExecute&gt;
  </code></pre>
  
  <p>In the course of a full day, around 300 executions (of >2M) will yield the following exception:</p>
  
  <pre>
  System.Xml.Schema.XmlSchemaValidationException
  The 'http://www.w3.org/2000/xmlns/:mssql' attribute is not declared.
  </pre>
  
  <p>The schema validator seems to complain about the namespace declaration. </p>
  
  <p>The code structure is as follows:</p>
  
  <ul>
  <li>There is a static instance of XmlSchemaSet;</li>
  <li>Initialization of the XmlSchemaSet instance is being done in a thread-safe manner;</li>
  <li>Each worker thread makes use of the same XmlSchemaSet;</li>
  <li>The validation occurs during an XmlSerializer.Deserialize() call, using an XmlReader with XmlReaderSettings initialized with ValidationType.Schema.</li>
  </ul>
  
  <p>Any thoughts on what might be causing the validation to choke with the namespace declaration?</p>