XmlSerializer.Serialize

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    XmlSerializer.Serialize

    Hey,


    I have made a method that would take any object o and an array of
    extraTypes to construct a XmlSerializer object then call .Serialize(stre am,
    object)... When I have this called within the same method as the type it
    works fine but when I am passing this type and the extra types array Its got
    the subtypes but its not generating the XML.

    I am passing in ob.GetType(), and xtraTypes as the constructor parameters
    to XmlSerializer(. .)

    According to the debugger it has the type, the data and subtypes ok, its
    just not serializing it to XML properely.

    Is this odd behaviour of the Serializer?



  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: XmlSerializer.S erialize

    Can you give a small example? Is there an error?

    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    <discussion@dis cussion.microso ft.com> wrote in message
    news:%23HMUUi4p DHA.2404@TK2MSF TNGP12.phx.gbl. ..[color=blue]
    > Hey,
    >
    >
    > I have made a method that would take any object o and an array of
    > extraTypes to construct a XmlSerializer object then call[/color]
    ..Serialize(str eam,[color=blue]
    > object)... When I have this called within the same method as the type it
    > works fine but when I am passing this type and the extra types array Its[/color]
    got[color=blue]
    > the subtypes but its not generating the XML.
    >
    > I am passing in ob.GetType(), and xtraTypes as the constructor[/color]
    parameters[color=blue]
    > to XmlSerializer(. .)
    >
    > According to the debugger it has the type, the data and subtypes ok, its
    > just not serializing it to XML properely.
    >
    > Is this odd behaviour of the Serializer?
    >
    >
    >[/color]


    Comment

    • Guest's Avatar

      #3
      Re: XmlSerializer.S erialize

      There is no error reported. I just have the usual serializer call with the
      object.GetType( ) in the first parameter and the extra types for the array of
      objects , it works fine in the inline but as a generalized method its not
      serializing the array of types.

      I am passing in to the generaliezd one as generalSerializ er(object o,
      Type[] t) and passing in o.GetType(), and t[0] = someType.GetTyp e(); I
      even tried typeof(blah.bla h) and same result.





      "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote in
      message news:OswMXR5pDH A.1928@TK2MSFTN GP12.phx.gbl...[color=blue]
      > Can you give a small example? Is there an error?
      >
      > --
      > - Nicholas Paldino [.NET/C# MVP]
      > - mvp@spam.guard. caspershouse.co m
      >
      > <discussion@dis cussion.microso ft.com> wrote in message
      > news:%23HMUUi4p DHA.2404@TK2MSF TNGP12.phx.gbl. ..[color=green]
      > > Hey,
      > >
      > >
      > > I have made a method that would take any object o and an array of
      > > extraTypes to construct a XmlSerializer object then call[/color]
      > .Serialize(stre am,[color=green]
      > > object)... When I have this called within the same method as the type[/color][/color]
      it[color=blue][color=green]
      > > works fine but when I am passing this type and the extra types array Its[/color]
      > got[color=green]
      > > the subtypes but its not generating the XML.
      > >
      > > I am passing in ob.GetType(), and xtraTypes as the constructor[/color]
      > parameters[color=green]
      > > to XmlSerializer(. .)
      > >
      > > According to the debugger it has the type, the data and subtypes ok,[/color][/color]
      its[color=blue][color=green]
      > > just not serializing it to XML properely.
      > >
      > > Is this odd behaviour of the Serializer?
      > >
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...