title: XMLDocument.Validate Error: System.InvalidOperationException : The XmlSchemaSet on the document is either null or has no schemas in it
body: <p>I got this weird error when I wanted to validate my in-memory xml Schema, anything I did wrong?</p>
  
  <pre><code>    [Test]
      public void ValidationXML()
      {
          int errorCount = 0;
          var xmlString = "&lt;?xml version='1.0'?&gt;&lt;response&gt;&lt;error code='1'&gt; Success&lt;/error&gt;&lt;/response&gt;";
          XmlDocument xmlDocument = new XmlDocument();
          xmlDocument.LoadXml(xmlString);
          xmlDocument.Validate((sender, e) =&gt; errorCount++);
          Assert.AreEqual(0, errorCount);
      }
  </code></pre>
  
  <p>The exception was:</p>
  
  <pre><code> failed: System.InvalidOperationException : The XmlSchemaSet on the document is either null or has no schemas in it. Provide schema information before calling Validate.
      at System.Xml.XmlDocument.Validate(ValidationEventHandler validationEventHandler, XmlNode nodeToValidate)
      at System.Xml.XmlDocument.Validate(ValidationEventHandler validationEventHandler)
  </code></pre>