By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,286 Members | 2,364 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,286 IT Pros & Developers. It's quick & easy.

xsd tool/serialization problem...wrong xml ?

P: n/a
I was trying to deserialize my xml file (I enclose it below ) into a class.
So I generated an xsd file given my xml using the MS xsd tool; then I
generated the corresponsing C# class (using the MS xsd tool): the
UserSecurityData class. When I try to execute my app to deserialize my xml
file, my application crashes causing a strange FileNotFoundException when
invoking the XmlSerializer constructor (second line of my code fragment). Is
there anything wrong with my xml file ?

Thank you for yor help
Andrea
////////////////////////////////////////////////////////////////////////////
/////////

UserSecurityData newList;
XmlSerializer s = new XmlSerializer( typeof( UserSecurityData ) );

TextReader tr = new StreamReader("token.xml" );

newList = (UserSecurityData)s.Deserialize( tr );

//////////////////////////////////////////////////////////////xml file

<?xml version="1.0" encoding="ISO-8859-1"?>
<UserSecurityData>
<SecurityEntities>
<User name="D" value="1">
<UserPARAMETER name="CODE" value="D"/>
<UserPARAMETER name="FORCECHANGEPWD" value="0"/>
<UserPARAMETER name="LASTCHANGEPWD" value="20/10/2004"/>
<UserPARAMETER name="NUMBERLOGINERROR" value="0"/>
<UserPARAMETER name="LASTLOGIN" value="11/11/2004"/>
<UserPARAMETER name="DISABLED" value="0"/>
<UserPARAMETER name="LASTWRONGLOGIN" value="26/08/2004"/>
<UserPARAMETER name="PWDLIFE" value="0"/>
<UserPARAMETER name="SURNAME" value="Prodotto"/>
<UserPARAMETER name="NAME" value="Amministratore"/>
</User>
<Applications>
<Application name="Consolle"/>
</Applications>
<Representeds>
<Represented name="2181" value="127">
<RepresentedPARAMETER name="CODE" value="2181"/>
<RepresentedPARAMETER name="SURNAME" value="Valentini"/>
<RepresentedPARAMETER name="NAME" value="Gianluca"/>
</Represented>
</Representeds>
<Realm name="Amministrazione"/>
<Current name="utente"/>
</SecurityEntities>
<EncryptedArea/>
<ExtendedArea>
<ExtendedAreaPARAMETER name="TIMEOUT" value="900000"/>
<ExtendedAreaPARAMETER name="TIMESTAMP" value="1100164942328"/>
</ExtendedArea>
</UserSecurityData>

Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Andrea,

Can you take a look at [0] and try to diagnose the FileNotFoundException
with the XmlSerializerPreCompiler?

HTH,
Christoph Schittko
MS MVP XML
http://weblogs.asp.net/cschittko

[0]
http://msdn.microsoft.com/xml/defaul...n-us/dnxmlnet/
html/trblshtxsd.asp
-----Original Message-----
From: Andrea [mailto:andreno_spamalmieri@enmo_spam.m]
Posted At: Monday, November 15, 2004 5:30 AM
Posted To: microsoft.public.dotnet.xml
Conversation: xsd tool/serialization problem...wrong xml ?
Subject: xsd tool/serialization problem...wrong xml ?

I was trying to deserialize my xml file (I enclose it below ) into a
class.
So I generated an xsd file given my xml using the MS xsd tool; then I
generated the corresponsing C# class (using the MS xsd tool): the
UserSecurityData class. When I try to execute my app to deserialize my xml file, my application crashes causing a strange FileNotFoundException when invoking the XmlSerializer constructor (second line of my code fragment). Is
there anything wrong with my xml file ?

Thank you for yor help
Andrea
////////////////////////////////////////////////////////////////////////
// //
/////////

UserSecurityData newList;
XmlSerializer s = new XmlSerializer( typeof( UserSecurityData ) );

TextReader tr = new StreamReader("token.xml" );

newList = (UserSecurityData)s.Deserialize( tr );

//////////////////////////////////////////////////////////////xml file

<?xml version="1.0" encoding="ISO-8859-1"?>
<UserSecurityData>
<SecurityEntities>
<User name="D" value="1">
<UserPARAMETER name="CODE" value="D"/>
<UserPARAMETER name="FORCECHANGEPWD" value="0"/>
<UserPARAMETER name="LASTCHANGEPWD" value="20/10/2004"/>
<UserPARAMETER name="NUMBERLOGINERROR" value="0"/>
<UserPARAMETER name="LASTLOGIN" value="11/11/2004"/>
<UserPARAMETER name="DISABLED" value="0"/>
<UserPARAMETER name="LASTWRONGLOGIN" value="26/08/2004"/>
<UserPARAMETER name="PWDLIFE" value="0"/>
<UserPARAMETER name="SURNAME" value="Prodotto"/>
<UserPARAMETER name="NAME" value="Amministratore"/>
</User>
<Applications>
<Application name="Consolle"/>
</Applications>
<Representeds>
<Represented name="2181" value="127">
<RepresentedPARAMETER name="CODE" value="2181"/>
<RepresentedPARAMETER name="SURNAME" value="Valentini"/> <RepresentedPARAMETER name="NAME" value="Gianluca"/>
</Represented>
</Representeds>
<Realm name="Amministrazione"/>
<Current name="utente"/>
</SecurityEntities>
<EncryptedArea/>
<ExtendedArea>
<ExtendedAreaPARAMETER name="TIMEOUT" value="900000"/>
<ExtendedAreaPARAMETER name="TIMESTAMP" value="1100164942328"/> </ExtendedArea>
</UserSecurityData>

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.