xml serialization of private fields

Discussion in 'ASP .Net Web Services' started by Mark Itzcovitz, Jan 23, 2004.

  1. I have a web method that returns a struct, and all the fields in the struct,
    which are marked as public, get nicely serialized to xml. However, what I
    really want is the fields to be private so the struct can only be treated as
    a "black box". From everything I have read it seems that there is no way of
    having anything other than public fields automatically serialized. Can
    anyone tell me if I'm missing something?

    Thanks,

    Mark
     
    Mark Itzcovitz, Jan 23, 2004
    #1
    1. Advertising

  2. Mark Itzcovitz

    Jan Tielens Guest

    That's right, by default only public properties and fields are serialized.

    To overcome this you can write your own serializer and de-serializer. For
    more info check out following links:
    http://www.dotnet247.com/247reference/msgs/4/21971.aspx
    http://tinyurl.com/2fgup

    --
    Greetz

    Jan Tielens
    ________________________________
    Read my weblog: http://weblogs.asp.net/jan


    "Mark Itzcovitz" <> wrote in message
    news:...
    > I have a web method that returns a struct, and all the fields in the

    struct,
    > which are marked as public, get nicely serialized to xml. However, what I
    > really want is the fields to be private so the struct can only be treated

    as
    > a "black box". From everything I have read it seems that there is no way

    of
    > having anything other than public fields automatically serialized. Can
    > anyone tell me if I'm missing something?
    >
    > Thanks,
    >
    > Mark
    >
    >
     
    Jan Tielens, Jan 23, 2004
    #2
    1. Advertising

  3. Thanks, I'll bear that in mind if I decide I can't live with the fields
    being public.

    "Jan Tielens" <> wrote in message
    news:%...
    > That's right, by default only public properties and fields are serialized.
    >
    > To overcome this you can write your own serializer and de-serializer. For
    > more info check out following links:
    > http://www.dotnet247.com/247reference/msgs/4/21971.aspx
    > http://tinyurl.com/2fgup
    >
    > --
    > Greetz
    >
    > Jan Tielens
    > ________________________________
    > Read my weblog: http://weblogs.asp.net/jan
    >
    >
    > "Mark Itzcovitz" <> wrote in message
    > news:...
    > > I have a web method that returns a struct, and all the fields in the

    > struct,
    > > which are marked as public, get nicely serialized to xml. However, what

    I
    > > really want is the fields to be private so the struct can only be

    treated
    > as
    > > a "black box". From everything I have read it seems that there is no way

    > of
    > > having anything other than public fields automatically serialized. Can
    > > anyone tell me if I'm missing something?
    > >
    > > Thanks,
    > >
    > > Mark
    > >
    > >

    >
    >
     
    Mark Itzcovitz, Jan 23, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    8
    Views:
    2,314
    deadsea
    Jan 2, 2005
  2. qazmlp
    Replies:
    19
    Views:
    829
    Daniel T.
    Feb 4, 2004
  3. Replies:
    3
    Views:
    1,087
  4. Dimitri Ognibene
    Replies:
    4
    Views:
    824
    Dimitri Ognibene
    Sep 2, 2006
  5. Ramunas Urbonas
    Replies:
    1
    Views:
    427
    Dino Chiesa [Microsoft]
    Jul 27, 2004
Loading...

Share This Page