Using the following code, I got extra information on the error
try
{
hr = pSchemas->add("",pSchema.GetInterfacePtr());
}
catch(_com_error &error)
{
dump_com_error(error);
}
And the error was: (translated from french)
The namespace "" provided si different from the target namespace "http://tempuri.org/Device.xsd" of the schema.
When I generate the XSD file with Visual Studio 2010, it starts the file with:
<xs:schema id="Device"
targetNamespace="http://tempuri.org/Device.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/Device.xsd"
xmlns:mstns="http://tempuri.org/Device.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
The solution is to use the
targetNamespace
value as the first parameter of
add
method.