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 7417327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:40:47+00:00 2026-05-29T07:40:47+00:00

How do I specify the ProtoBuf-Net attributes in classes of a WebReference? I have

  • 0

How do I specify the ProtoBuf-Net attributes in classes of a WebReference?

I have a .net 2.0 Web Service in which I am creating a byte[] using protobuf.
In my client (v3.5) I want to deserialize the byte[] into the respective class.
However, when I deserialize all I get is 0 and nulls.

The reason for this is I specify the type as the Web Reference class.

Does Not Work Correctly

using (MemoryStream stream = new MemoryStream(byteArray))
{
            List<WebReferencePerson> personsList =  Serializer.DeserializeWithLengthPrefix<List<WebReferencePerson>>(stream, PrefixStyle.Base128);
            stream.Close();
}

However, if I create another class Person1 in the client and specify the Proto attributes [ProtoContract] and [ProtoMember()], I get the correct data deserialized.
i.e.

[ProtoContract]
class Person1
{
    [ProtoMember(1)]
    string Name {get;set;}
    [ProtoMember(2)]
    int Id {get;set;}
}

This works fine.

List<Person1> personsList = 
Serializer.DeserializeWithLengthPrefix<List<Person1>>(stream, PrefixStyle.Base128);

Isn’t there a way to use the classes from the Web Reference to deserialize the data?
How can I specify the Protobuf attributes to Web Reference class?
OR
Do I have to specify a different class with the Proto attributes to deserialize the data from a WebService?

  • 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-29T07:40:49+00:00Added an answer on May 29, 2026 at 7:40 am

    The asmx-generated types won’t have tag-markers markers; there are a number of ways of getting around this:

    • deserialize into the protobuf DTO
    • use a partial class to tell it about the layout
    • define the layout in code

    The second option would look like:

    namespace Your.Namespace {
        [ProtoContract]
        [ProtoPartialMember(1, "Name")]
        [ProtoPartialMember(2,  "Id")]
        partial class WebReferencePerson {}
    }
    

    The third option would be, as part of app-start:

    RuntimeTypeModel.Default.Add(typeof(WebReferencePerson), false)
                        .Add("Name", "Id");
    

    With either of these approaches it should then deserialize.

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

Sidebar

Related Questions

I am using Protobuf.net to serialize some classes. I would like to be able
I have List<HtmlAgilityPack.HtmlNode> but protobuf-net gives me error that it doesn't have a contract.
I want to specify a signal handler in Perl, but using the number, not
I'm trying to specify a constraint in my ontology: Let's say I have classes
I would like to specify that I want FEATURE_INDETERMINATE_PROGRESS for my Activity . It
How can I specify that a particular parametrized type needs to have a particular
In emacs I can specify that a file is SQL using this notation: --
You can specify in your maven settings file that you want to run in
Is it possible to specify different access modifiers for property getter and setter using
Specify a $target,then it'll flash itself toward $target, it's used to inform user which

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.