c# - XMLDocument.Validate Error: System.InvalidOperationException : The XmlSchemaSet on the document is either null or has no schemas in it -


When I wanted to verify my in-memory xml schema, I found this strange error, did I do anything wrong?

  [Test] Public Zero Validation XML () {int errorCount = 0; On xmlString = "& lt ;? xml version = '1.0'> ?? 
  • response & gt; error code = '1' & gt; success & lt; / error & gt; & lt; / Reaction & gt; "; XmlDocument xmlDocument = New XmlDocument (); XmlDocument.LoadXml (xmlString); XmlDocument.Validate ((sender, e) = & gt; error code +); Assurance First (0, error code); }
  • The exception was:

      failed: System.InvalidOperationException: XmlSchemaSet on the document is either empty or has a schema in it. Provide schema information before making a valid call System.Xml.XmlDocument.Validate (ValidationEventHandler validationEventHandler)  

    You are trying to validate a schema describing XmlDocument

      xmlDocument .Schemas.Add (New XmlSchema ());  

    To verify it in front of an empty schema (as opposed to zero) and verification will fail (instead of throwing an exception), 1 to set ERRORCOUNT tries to.


    Comments

    Popular posts from this blog

    c# - PInvoke of NetUserAdd returns 24 -