473,662 Members | 2,454 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XmlSerialzer error when multiple nillable elements of userdefined

Hi i am getting the following error while using XMLSerializer
XmlSerializer ser = new XmlSerializer(t ypeof(Person));

ERROR:
Unable to generate a temporary class (result=1).
error CS0266: Cannot implicitly convert type 'XSD.BiodataGen der?' to
'XSD.BiodataRac e?'. An explicit conversion exists (are you missing a cast?)

I am getting the above error when my xsd has multiple nillable elements of
userdefined type. If I change the type of either race or gender to String i
am getting any error. temporary class is generated easily

MY XSD :
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema targetNamespace ="http://my/ex" xmlns:version1= "http://my/ex"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema">
<xsd:element name="person" type="version1: Person" />
<xsd:complexTyp e name="Person">
<xsd:sequence >
<xsd:element name="biodata" type="version1: Biodata" minOccurs="1"
maxOccurs="1" />
</xsd:sequence>
</xsd:complexType >
<xsd:complexTyp e name="Biodata">
<xsd:sequence >
<xsd:element name="gender" nillable="true" >
<xsd:simpleType >
<xsd:restrictio n base="xsd:strin g">
<xsd:enumeratio n value="M" />
<xsd:enumeratio n value="F" />
</xsd:restriction >
</xsd:simpleType>
</xsd:element>
<xsd:element name="race" nillable="true" >
<xsd:simpleType >
<xsd:restrictio n base="xsd:strin g">
<xsd:enumeratio n value="AI" />
<xsd:enumeratio n value="AS" />
</xsd:restriction >
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType >
</xsd:schema>

Code Generated by xsd.exe:

namespace XSD
{

/// <remarks/>
[System.CodeDom. Compiler.Genera tedCodeAttribut e("cxsc", "0.57.0.0")]
[System.Serializ ableAttribute()]
[System.Diagnost ics.DebuggerSte pThroughAttribu te()]
[System.Componen tModel.Designer CategoryAttribu te("code")]
[System.Xml.Seri alization.XmlTy peAttribute(Nam espace="http://my/ex")]
[System.Xml.Seri alization.XmlRo otAttribute("pe rson",
Namespace="http ://my/ex", IsNullable=fals e)]
public partial class Person
{
/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( Form=System.Xml .Schema.XmlSche maForm.Unqualif ied)]
public Biodata biodata;
}
/// <remarks/>
[System.CodeDom. Compiler.Genera tedCodeAttribut e("cxsc", "0.57.0.0")]
[System.Serializ ableAttribute()]
[System.Diagnost ics.DebuggerSte pThroughAttribu te()]
[System.Componen tModel.Designer CategoryAttribu te("code")]
[System.Xml.Seri alization.XmlTy peAttribute(Nam espace="http://my/ex")]
public partial class Biodata
{
/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( Form=System.Xml .Schema.XmlSche maForm.Unqualif ied, IsNullable=true )]
public System.Nullable <BiodataGenderg ender;
/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( Form=System.Xml .Schema.XmlSche maForm.Unqualif ied, IsNullable=true )]
public System.Nullable <BiodataRacerac e;
}
/// <remarks/>
[System.CodeDom. Compiler.Genera tedCodeAttribut e("cxsc", "0.57.0.0")]
[System.Serializ ableAttribute()]
[System.Xml.Seri alization.XmlTy peAttribute(Ano nymousType=true ,
Namespace="http ://my/ex")]
public enum BiodataGender
{
/// <remarks/>
M,
/// <remarks/>
F,
}
/// <remarks/>
[System.CodeDom. Compiler.Genera tedCodeAttribut e("cxsc", "0.57.0.0")]
[System.Serializ ableAttribute()]
[System.Xml.Seri alization.XmlTy peAttribute(Ano nymousType=true ,
Namespace="http ://my/ex")]
public enum BiodataRace
{
/// <remarks/>
AI,
/// <remarks/>
AS,
}
}
Nov 9 '07 #1
0 3046

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1435
by: Marty McDonald | last post by:
If I try to validate this xml... <?xml version="1.0" encoding="utf-8" ?> <a:FuncalcParameters xmlns:a="http://www.somewhere.fun.com/Funcalc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.somewhere.fun.com/Funcalc http://localhost/FuncalcService/FuncalcParameters.xsd"> <TransId>D-288</TransId> <CalcType>CalculateARM</CalcType> <SR>5</SR> <RRT></RRT>
1
1534
by: tushar | last post by:
Hi I am trying to use XMLSerialzer class to generate serializable class for following schema. <xs:element name="KeyIdentifiers" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="KeyIdentifier" minOccurs="0" maxOccurs="unbounded">
3
5057
by: Jerome Cohen | last post by:
AI am trying to call a third-party web service. this service expects an XML fragment that contains the request plus other parameter. adding the web reference created the syntax below(reference.vb). I changed the data type for the structure that contains the XML data from the default "String" to "xml.xmldocument" to enable easy filling of the data. my client code creates an XML document class, fills the data using standard xml dom...
7
3085
by: Jorgen Haukland, Norway | last post by:
Hi, I have created a Java webservice which runs in IBM WebSphere appserver. I take the WSDL-file and create a VS.NET WinForm application and calls the service running on my PC and everything works fine. So I deploy the webservice on a remote machine (Linux box) and I get an error when calling the service. BUT: I can retrieve the WSDL and make a webreference in my VS.NET project, so obviously I (or more correct: My VS.NET project) am...
1
1790
by: manfred | last post by:
Hi Together, I tried to build a webservice proxy using a wsdl, generated in the sun/java world. I used the .Net 2003 Version, choosing there VC++. The steps I did: 1. Visual C++ Projekte / "Konsoleanwendung (.Net)" 2. Projekt / Webverweis hinzufügen / lokal I chose the wsdl, which were generated before within a WSAD environment (style: RPC encoded). For me the wsdl looks like ok:
669
25860
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
1
1644
by: Vishuonline | last post by:
Guys, I have had some experience in working with webservices created in .NET but this is the first time I am trying out one made in Java. When I run the wsdl exe to create a proxy class for the wsdl provided it throws the following error. Error: Unable to import binding 'CosmosXXXXXBinding' from namespace 'urn :XXXXX'.
3
6094
by: Jeremy Chapman | last post by:
I've writtin a very simple web service in axis which returns an array of classes. I consume it in a .net app. When receiving the response, my .net app generates an error "Cannot assign object of type System.Object to an object of type PersonWS.WorkGroupData.". I've included the wsdl of the consumed axis web service, the request/responses of the web service by the .net app and the exception and stack trace. Hoping someone can tell me...
0
1113
by: =?Utf-8?B?a3Jpc2huYQ==?= | last post by:
Hi i am getting the following error while using XMLSerializer XmlSerializer ser = new XmlSerializer(typeof(Person)); ERROR: Unable to generate a temporary class (result=1). error CS0266: Cannot implicitly convert type 'XSD.BiodataGender?' to 'XSD.BiodataRace?'. An explicit conversion exists (are you missing a cast?) I am getting the above error when my xsd has multiple nillable elements of userdefined type. If I change the type of...
0
8432
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8343
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8545
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7365
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6185
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.