Home All Groups Group Topic Archive Search About

xsd tool/serialization problem...wrong xml ?

Author
15 Nov 2004 11:29 AM
Andrea
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>

Author
15 Nov 2004 5:25 PM
Christoph Schittko [MVP]
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/default.aspx?pull=/library/en-us/dnxmlnet/
html/trblshtxsd.asp

Show quote
> -----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"/>
Show quote
>     </ExtendedArea>
> </UserSecurityData>
>
>
>

AddThis Social Bookmark Button

Post Other interesting topics