views:

43

answers:

1

I am trying to create a DataContract for a simple REST based webservice using a XSD file.

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="workcodes" xmlns="http://timesheet.domain.com/webservices/workcodes" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="unqualified" elementFormDefault=”qualified”>
    <xs:element name="workcodes">
            <xs:complexType>
           <xs:sequence>
              <xs:element name="code" type="xs:string" />
           </xs:sequence>
       </xs:complexType>
    </xs:element>
</xs:schema>

However when I run:

svcutil /dconly .\workcodes.xsd /out:workcodes.cs

I get the following error message:

Error: Cannot read .\workcodes.xsd.

Cannot load file C:\home\timesheet_webpart\workcodes.xsd as an Assembly. Check the FusionLogs for more Information.

Could not load file or assembly 'file:///C:\home\timesheet_webpart\workcodes.xsd' or one of its dependencies. The module was expected to contain an assembly manifest.

I do not know why it would be trying to load the XSD as an assembly. I researched the issue and was unable to find a solution.

Can anyone shed some light on this issue?

Thanks

A: 

The answer was that there was a syntax error in the XSD schema:

attributeFormDefault="unqualified" elementFormDefault=”qualified”

The double quotes around elementFormDefault are the wrong characters, meaning that svcutil could not validate the schema and tried to load it as an assembly. Replacing with:

attributeFormDefault="unqualified" elementFormDefault="qualified"

fixes the issue and the data contract is generated.

Watch for subtle syntax errors when you see this error.

Servicad