"Type 'http://www.w3.org/2000/09/xmldsig#:SignatureType' is not declared" in XmlDocument.Validate(...)
<p>I have this very simple XSD schema</p>

<pre><code>&lt;?xml version = "1.0" encoding = "UTF-8"?&gt;
&lt;schema xmlns = "http://www.w3.org/2001/XMLSchema"
     targetNamespace = "http://my.domain/xmlschemas/message"
     xmlns:mmm = "http://my.domain/xmlschemas/message"
     xmlns:ds = "http://www.w3.org/2000/09/xmldsig#"
     xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
     elementFormDefault = "qualified"&gt;
    &lt;import namespace = "http://www.w3.org/2000/09/xmldsig#" schemaLocation = "xmldsig-core-schema.xsd"/&gt;
  &lt;element name = "message"&gt;
        &lt;complexType&gt;
            &lt;sequence&gt;  
                 &lt;element name = "Signature" type = "ds:SignatureType" minOccurs = "0" maxOccurs = "unbounded"/&gt;
            &lt;/sequence&gt;
        &lt;/complexType&gt;
    &lt;/element&gt;
&lt;/schema&gt;
</code></pre>

<p>stored as an embedded resource of my Visual Studio 2010 C# project as well as <code>xmldsig-core-schema.xsd</code>, which I downloaded from <code>www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd</code>.</p>

<p>I would like to validate my document against this XSD schema. My document:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;message xmlns="http://my.domain/xmlschemas/message"&gt;
&lt;/message&gt;
</code></pre>

<p>I use <code>XmlDocument.Validate(...)</code> method for validation this way:</p>

<pre><code>XmlDocument doc = new XmlDocument();
doc.PreserveWhitespace = true;
doc.Load(inputStream); //XML document loads correctly...

Assembly myAssembly = Assembly.GetExecutingAssembly();
using (Stream schemaStream = myAssembly.GetManifestResourceStream("XmlSigTest.Resources.message.xsd"))
{
     XmlSchema schema = XmlSchema.Read(schemaStream, null);
     doc.Schemas.Add(schema); //XSD schema loads correctly
}

bool ok = true;
doc.Validate((s, e) =&gt; //throws Exception!!!
{
     ok = false;
});
</code></pre>

<p>This code throws an exception in <code>doc.Validate(...)</code> with message: <code>Type 'http://www.w3.org/2000/09/xmldsig#:SignatureType' is not declared</code>. However, there is no warning or error in Visual Studio XML Editor and I can see <code>SignatureType</code> in Visual Studio XML Schema Explorer. Why is this exception thrown? What should I do?</p>