Pages

Generating Serialized Classes From Xsd.exe with XSD Schema Imports

Thursday, September 1, 2011
Q:

Hi  Guys I'm Facing problem generating Serialized classes from schema which has multiple imports in my canonical schema

It worked previously when i generated for a individual schema without any imports ?.
can you help me on this Im getting Error : Error Generating Classes for xxx.schema

Sol:

Hi there,

You need to add the Import Schema's along with  the Schema for which you are generating Serialized Classes You need to Add the import Schemas/Referenced Schemas Also while generating the serialized Classes


Below is an example:
Generating Serialized Classes Using XSD.EXE
C:\Program Files (x86)\Microsoft Visual Studio 8\VC>
xsd  C:\AOP\ISIS\Common\Schemas\ISIS.Common.Schemas.AdditionalInfo\AdditionalInfo.xsd C:\AOP\ISIS\Common\Schemas\ISIS.Common.Schemas.MessageHeader\MessageHeader.xsd C:\AOP\ISIS\Common\Schemas\ISIS.Common.Schemas.TransactionResult\TransactionResult.xsd C:\AOP\CIS\Common\Schemas\CIS.Common.Schemas.ActivateParkedDevice\ActivateParkedDeviceResponse.xs
d /l:cs /n:CIS.Common.Schemas.ActivateParkedDevice.Helper /outputdir:C:\AOP\CIS\
Common\Schemas\CIS.Common.Schemas.ActivateParkedDevice.Helper /c
 
After Execute : Result:

Microsoft (R) Xml Schemas/DataTypes support utility[Microsoft (R) .NET Framework, Version 2.0.50727.42]
Copyright (C) Microsoft Corporation. All rights reserved.Writing file 'C:\AOP\CIS\Common\Schemas\CIS.Common.Schemas.ActivateParkedDevice.
Helper\ActivateParkedDeviceResponse.cs'.


Here
i was generating the generating the Serialized class for Activate Parked device response Schema which had XSD imports for Additional Info Schema and Transaction result Schema
 you need to add the reference as specified as Reference Schema's , Actual Schema , Generating Parameters.

Note: Sometimes if you are generating Multiple Schema's with the same imports under the same namespace  you will need to generate the Serialized classes the same way for both but the Generated Serialized Class may not be valid as there will be duplicate methods with in the same namespace
"You Need to remove the Redundant Classes Generated with same Name  or Generate Schema's under different Namespaces"

No comments:

Post a Comment

Post Your Comment...