Q:

Loading Embedded XSD with Imports into DataSet

My goal is to load an embedded xsd with imports into a DataSet and then generate tables based on the xsd.
I am attempting to load a DataSet with an XML Schema consisting of multiple XSD files that are imported.  Doing this with the files sitting on the file system is no problem, I just hand it the main xsd file and everything loads fine and all xsd imports are resolved.  What I would like to do is have my xsd embedded in my dll so it isn't sitting around on the file system.  The project that has the embedded xsd files is separate from the project that will be accessing the xsd files to load into a DataSet.
The DataSet.ReadXmlSchema method can take either a stream, XmlReader, string uri, or XmlTextReader.  I have no problem loading up the dll and then getting to the main schema file using assembly.GetManifestResourceStream(schemaPath), which would be fine if my schema was just one file. The problem is that once I pass this to the DataSet.ReadXmlSchema method it is unable to find any of the imports.
I tried using the XmlReader and using an XmlReaderSettings object with a custom xml resolver I had written for a previous problem(and I know works).  I had used the custom xml resolver in the past to load up a similar schema embedded into a dll into an XmlSchemaSet and it worked like a charm.  So when I make the XmlReader.Create call I pass in the XmlReaderSettings that uses my custom Xml Resolver, but when I pass this XmlReader to the DataSet.ReadXmlSchema method it also can't find the imported schema files.  I set a breakpoint in the overloaded GetEntity method and it is never hit.  So the XmlReader doesn't seem to use the XmlResolver I have provided.  I had the same issue with the XmlTextReader.
Any ideas on how I could go about loading up an embedded schema with imports into a DataSet?  My last resort is to copy the embedded xsd files to the file system temporarily to create the DataSet and then delete them, although I am trying to avoid this.

A:

Unfortunately, no, it is not possible to load a DataSet from multiple XSDs embedded as resources.
The justification is in this method of the DataSet class:
internal void ReadXSDSchema(XmlReader reader, bool denyResolving)
The way the code is written there, it makes use of a XmlSchemaSet; it uses the reader you pass (XmlReader) to load the schema, add it to the XmlSchemaSet and compile.
Unfortunately, to compile an XmlSchemaSet when using embedded resources, one must provide an xml resolver to the XmlSchemaSet object!... the thing is, there isn't one that can be used at that point in the process. While the reader settings may be configured with a resolver, as you know, it is Write only (there's no getter).
To test what I've said, try to load an XmlSchemaSet from the same embedded resources; you'll notice that not matter what you're trying, the resolver must be set at the XmlSchemaset level, not at the XmlReader level.
I suggest you to take a look at the exception stack, and then use Reflector or something like that to look at the code. If you reach a different conclusion, please share.

