Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 602061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:46:55+00:00 2026-05-13T16:46:55+00:00

I’m quite new to Silverlight. I’m working for a project which mainly depends on

  • 0

I’m quite new to Silverlight. I’m working for a project which mainly depends on Serialization and Deserialization.

Formerly, for WPF I was comfortable with Serializable classes. For silverlight, I found protobuf would be quite useful. But, I’m troubled with this exception. I don’t know what causes this problem. Please help me out.

I’m using Silverlight 3.0.
protobuf-net r282

Please find the code which I’m using.

[ProtoContract]
public class Report
{
    public Report()
    {
    }

    [ProtoMember(1)]
    public SubReports SubReports { get; set; }
}

[ProtoContract]
public class SubReports
   : List<SubReport>
{
    public SubReports()
    {
    }

    [ProtoMember(1)]
    public SubReport SubReport { get; set; }
}

[ProtoContract]
public class SubReport
{
    public SubReport()
    {
    }

    [ProtoMember(1)]
    public string Name { get; set; }
}

The Code I’m using to de-serialize is

    public static T Deserialize<T>(Byte[] bytes) where T
        : Report
    {
        return ProtoBuf.Serializer.Deserialize<T>(new MemoryStream(bytes));
    }

My sample XML looks similar to

Report  
   ...SubReports  
      ...SubReport Name=”Q1 Report”   
      ...SubReport Name=”Q2 Report”   
      ...SubReport Name=”Q3 Report”   
      ...SubReport Name=”Q4 Report”     

Thanks in advance.
Vinodh

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:46:55+00:00Added an answer on May 13, 2026 at 4:46 pm

    (note: I couldn’t reproduce the “group tags” issue; see edit history for my first thoughts on this, now removed; if you can help me reproduce this I’d be grateful)

    The problem is SubReports. You have defined this both as a list and as a serialization entity ([ProtoContract]); the latter takes precedence, so it was trying to serialize the single sub-report on the list (which is always null?).

    If you change this to:

    // note no attributes, no child property
    public class SubReports : List<SubReport> { }
    

    or if you remove it completely and make Report.SubReports a List<SubReport> it should work fine. The following works:

    static void Main() {
        byte[] blob;
        // store a report
        using (MemoryStream ms = new MemoryStream()) {
            Report report = new Report {
                SubReports = new List<SubReport> {
                    new SubReport { Name="Q1"}, 
                    new SubReport { Name="Q2"},
                    new SubReport { Name="Q3"},
                    new SubReport { Name="Q4"},
                }
            };
    
            Serializer.Serialize(ms, report);
            blob = ms.ToArray();
        }
        // show the hex
        foreach (byte b in blob) { Console.Write(b.ToString("X2")); }
        Console.WriteLine();
    
        // reload it
        using (MemoryStream ms = new MemoryStream(blob)) {
            Report report = Serializer.Deserialize<Report>(ms);
            foreach (SubReport sub in report.SubReports) {
                Console.WriteLine(sub.Name);
            }
        }
    }
    

    Displaying the blob:

    0A040A0251310A040A0251320A040A0251330A040A025134

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Being quite new to rails and currently building a project, i'm begining to be
Hi i m quite new to mvc and i m writing a report which
I am trying to use MVVM in Silverlight, but I am quite new to
Im quite new to silverlight and windows 7 phone development. And I'm not sure
in my Silverlight 4 application, I save my object via DataContractSerializer XML-Serialization - which
Quite new to maven here so let me explain first what I am trying
Im quite new to spring mvc. What I'm trying to achive is separating static
Scenario: Quite new to DI and Ninject but would love to master it so
Still quite new to Haskell.. I want to read the contents of a file,
Iam quite new to functions in SQL and I would like to create a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.