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

  • Home
  • SEARCH
  • 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 have List<HtmlAgilityPack.HtmlNode> but protobuf-net gives me error that it doesn't have a contract.
XAML allows you to specify an attribute value using a string that contains curly
If I do not specify the following in my web.xml file: <session-config> <session-timeout>10</session-timeout> </session-config>
I would like to specify a constraint which is another type with a generic
I want to specify a formula for the display string property of an object
Can I specify what file I want to write into in C++? I want
I want to specify that the size is 200dlu < preferred component size <
Specify a $target,then it'll flash itself toward $target, it's used to inform user which
How to specify NOW() BETWEEN col1 AND col2 using Kohana Database? $this->where(new Database_Expression('NOW()'), 'BETWEEN',
I need to specify command line arguments for a RemoteApp using the remoteapplicationcmdline property

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.