Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Can't serialize ArrayList
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Steven  
View profile  
 More options Nov 3, 1:47 am
Newsgroups: microsoft.public.dotnet.framework
From: Steven <Ste...@discussions.microsoft.com>
Date: Mon, 2 Nov 2009 06:47:02 -0800
Local: Tues, Nov 3 2009 1:47 am
Subject: Can't serialize ArrayList
Hi guys

I'm trying to serialize a class that includes an ArrayList member.  Here's
the class:

    [Serializable]
    public class InstantiationData
    {
        public string InstanceTaskAssignedTo;
        public string InstanceMailMsg;
        public DateTime InstanceDueDate;
        public Approvers ADApproversGroup;  // this is the ArrayList member //
    }

All other members of this class serialize properly, but the Approvers member
(a  class which implements IEnumerator) does not.  I've set a breakpoint
immediately after the Serialize method is called and inspected the object
which looks like this:

  <?xml version="1.0" ?>
 <InstantiationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <InstanceTaskAssignedTo>cs_ap</InstanceTaskAssignedTo>
  <InstanceMailMsg>Test message</InstanceMailMsg>
  <InstanceDueDate>2009-11-09</InstanceDueDate>
  <ADApproversGroup />
  </InstantiationData>

As you can see, the ADApproversGroup node is empty when serialized, but the
class instance shows 2 elements in the arrayList.

I've read that when serializing, it helps to specify the type of object I'm
serializing which I've done as follows:

XmlSerializer serializer = new XmlSerializer(typeof(InstantiationData));

But this doesn't help.  Any ideas how to serialize an ArrayList member of a
class?

Tks


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Duniho  
View profile  
 More options Nov 3, 5:52 am
Newsgroups: microsoft.public.dotnet.framework
From: Peter Duniho <no.peted.s...@no.nwlink.spam.com>
Date: Mon, 02 Nov 2009 10:52:05 -0800
Local: Tues, Nov 3 2009 5:52 am
Subject: Re: Can't serialize ArrayList

Steven wrote:
> Hi guys

> I'm trying to serialize a class that includes an ArrayList member.  Here's
> the class:

>     [Serializable]
>     public class InstantiationData
>     {
>         public string InstanceTaskAssignedTo;
>         public string InstanceMailMsg;
>         public DateTime InstanceDueDate;
>         public Approvers ADApproversGroup;  // this is the ArrayList member //
>     }

If it's an ArrayList member, why is the type "Approvers"?

It's practically impossible to say without a concise-but-complete code
example.  But, it should be obvious that to serialize a member of a
class, that member needs to be serializable, and if it's a collection,
the collection members need to be serializable.

Whether those are _sufficient_ conditions in your case, I can't say.
But for sure, they are necessary.

Pete


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
go  
View profile  
 More options Nov 3, 10:53 pm
Newsgroups: microsoft.public.dotnet.framework
From: go <gameover2...@gmail.com>
Date: Tue, 03 Nov 2009 12:53:45 +0100
Local: Tues, Nov 3 2009 10:53 pm
Subject: Re: Can't serialize ArrayList
Hello Steven. Always when I want to serialize a type I start with
creating an xml-schema for the type and then (auto-)generate the
classes. I think it saves time and trouble.
///M

Steven skrev:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google