Hi,
I'm trying to convert an XmlSchema object to string. I'm building a simple XmlSchema, compiling it, and then converting it as folows:
public string ConvertXmlSchemaToString(XmlSchema xmlSchema)
{
String SchemaAsString = String.Empty;
// compile the schema
XmlSchemaSet schemaSet = new XmlSchemaSet();
schemaSet.Add(xmlSchema);
schemaSet.ValidationEventHandler += new ValidationEventHandler(schemaSet_ValidationEventHandler);
schemaSet.Compile();
// allocate memory for string output
MemoryStream MemStream = new MemoryStream(1024);
xmlSchema.Write(MemStream);
MemStream.Seek(0, SeekOrigin.Begin);
StreamReader reader = new StreamReader(MemStream);
SchemaAsString = reader.ReadToEnd();
return SchemaAsString;
}
While running as a console app, everything works fine, but when running from Nunit I get an exception in the "xmlSchema.Write(MemStream);" line.
exception is : There was an error generating the XML document.
inner exception is : Common Language Runtime detected an invalid program.
Thanks,
Yossin