How to deserialize protobuf content from HttpResponseMessageHow do I calculate someone's age in C#?How do you give a C# Auto-Property a default value?How do I enumerate an enum in C#?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?How do I update the GUI from another thread?Get int value from enum in C#How do I generate a random int number?Deserialize JSON into C# dynamic object?how can i find repeated Customer detail in target table?What is a NullReferenceException, and how do I fix it?

Should I warn my boss I might take sick leave?

Is it bad to suddenly introduce another element to your fantasy world a good ways into the story?

Does the Milky Way orbit around anything?

Machine Learning Golf: Multiplication

What causes a fastener to lock?

How come a desk dictionary be abridged?

In the Seventh Seal why does Death let the chess game happen?

/api/sitecore is not working in CD server

How can select a specific triangle in my Delaunay mesh?

Did Stalin kill all Soviet officers involved in the Winter War?

What is it called when the tritone is added to a minor scale?

Why would "dead languages" be the only languages that spells could be written in?

What instances can be solved today by modern solvers (pure LP)?

What happens if the limit of 4 billion files was exceeded in an ext4 partition?

How serious is plagiarism in a master’s thesis?

How would a sea turtle end up on its back?

The Purpose of "Natu"

How can I effectively map a multi-level dungeon?

Advice for making/keeping shredded chicken moist?

Is it possible to spoof an IP address to an exact number?

How important is it for multiple POVs to run chronologically?

Red and White Squares

What can a novel do that film and TV cannot?

PhD: When to quit and move on?



How to deserialize protobuf content from HttpResponseMessage


How do I calculate someone's age in C#?How do you give a C# Auto-Property a default value?How do I enumerate an enum in C#?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?How do I update the GUI from another thread?Get int value from enum in C#How do I generate a random int number?Deserialize JSON into C# dynamic object?how can i find repeated Customer detail in target table?What is a NullReferenceException, and how do I fix it?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I'm trying to deserialize the response message from my database in protobuf format. It has this schema:



syntax = "proto3";

message Person
uint64 id = 1;
string name = 2;
string surname = 3;
uint32 age = 4;
;


and I created this class to deserialize it:



[ProtoContract]
public class Person

[ProtoMember(1)]
public long Id get; set;
[ProtoMember(2)]
public string Name get; set;
[ProtoMember(3)]
public string Surname get; set;
[ProtoMember(4)]
public int Age get; set;



Next, I tried to do this:



var response = await client.PostAsync("", new StringContent(request));
using (var responseStream = await response.Content.ReadAsStreamAsync())

var person = Serializer.Deserialize<Person>(responseStream);



But I cathed a ProtoBuf.ProtoException: Invalid wire-type;.



Then I decided to see at byte array:



25, 8, 1, 18, 6, 82, 111, 98, 101, 114, 116, 26, 11, 79, 112, 112, 101, 110, 104, 101, 105, 109, 101, 114, 32, 38 


And I created by hand an entry, that must be returned by my database, and serialize it:



8, 1, 18, 6, 82, 111, 98, 101, 114, 116, 26, 11, 79, 112, 112, 101, 110, 104, 101, 105, 109, 101, 114, 32, 38 


As you can see, they are almost the same, but my db send 25 at the start.



Could you help me, what could be the error?
Thanks!










share|improve this question






























    1















    I'm trying to deserialize the response message from my database in protobuf format. It has this schema:



    syntax = "proto3";

    message Person
    uint64 id = 1;
    string name = 2;
    string surname = 3;
    uint32 age = 4;
    ;


    and I created this class to deserialize it:



    [ProtoContract]
    public class Person

    [ProtoMember(1)]
    public long Id get; set;
    [ProtoMember(2)]
    public string Name get; set;
    [ProtoMember(3)]
    public string Surname get; set;
    [ProtoMember(4)]
    public int Age get; set;



    Next, I tried to do this:



    var response = await client.PostAsync("", new StringContent(request));
    using (var responseStream = await response.Content.ReadAsStreamAsync())

    var person = Serializer.Deserialize<Person>(responseStream);



    But I cathed a ProtoBuf.ProtoException: Invalid wire-type;.



    Then I decided to see at byte array:



    25, 8, 1, 18, 6, 82, 111, 98, 101, 114, 116, 26, 11, 79, 112, 112, 101, 110, 104, 101, 105, 109, 101, 114, 32, 38 


    And I created by hand an entry, that must be returned by my database, and serialize it:



    8, 1, 18, 6, 82, 111, 98, 101, 114, 116, 26, 11, 79, 112, 112, 101, 110, 104, 101, 105, 109, 101, 114, 32, 38 


    As you can see, they are almost the same, but my db send 25 at the start.



    Could you help me, what could be the error?
    Thanks!










    share|improve this question


























      1












      1








      1








      I'm trying to deserialize the response message from my database in protobuf format. It has this schema:



      syntax = "proto3";

      message Person
      uint64 id = 1;
      string name = 2;
      string surname = 3;
      uint32 age = 4;
      ;


      and I created this class to deserialize it:



      [ProtoContract]
      public class Person

      [ProtoMember(1)]
      public long Id get; set;
      [ProtoMember(2)]
      public string Name get; set;
      [ProtoMember(3)]
      public string Surname get; set;
      [ProtoMember(4)]
      public int Age get; set;



      Next, I tried to do this:



      var response = await client.PostAsync("", new StringContent(request));
      using (var responseStream = await response.Content.ReadAsStreamAsync())

      var person = Serializer.Deserialize<Person>(responseStream);



      But I cathed a ProtoBuf.ProtoException: Invalid wire-type;.



      Then I decided to see at byte array:



      25, 8, 1, 18, 6, 82, 111, 98, 101, 114, 116, 26, 11, 79, 112, 112, 101, 110, 104, 101, 105, 109, 101, 114, 32, 38 


      And I created by hand an entry, that must be returned by my database, and serialize it:



      8, 1, 18, 6, 82, 111, 98, 101, 114, 116, 26, 11, 79, 112, 112, 101, 110, 104, 101, 105, 109, 101, 114, 32, 38 


      As you can see, they are almost the same, but my db send 25 at the start.



      Could you help me, what could be the error?
      Thanks!










      share|improve this question
















      I'm trying to deserialize the response message from my database in protobuf format. It has this schema:



      syntax = "proto3";

      message Person
      uint64 id = 1;
      string name = 2;
      string surname = 3;
      uint32 age = 4;
      ;


      and I created this class to deserialize it:



      [ProtoContract]
      public class Person

      [ProtoMember(1)]
      public long Id get; set;
      [ProtoMember(2)]
      public string Name get; set;
      [ProtoMember(3)]
      public string Surname get; set;
      [ProtoMember(4)]
      public int Age get; set;



      Next, I tried to do this:



      var response = await client.PostAsync("", new StringContent(request));
      using (var responseStream = await response.Content.ReadAsStreamAsync())

      var person = Serializer.Deserialize<Person>(responseStream);



      But I cathed a ProtoBuf.ProtoException: Invalid wire-type;.



      Then I decided to see at byte array:



      25, 8, 1, 18, 6, 82, 111, 98, 101, 114, 116, 26, 11, 79, 112, 112, 101, 110, 104, 101, 105, 109, 101, 114, 32, 38 


      And I created by hand an entry, that must be returned by my database, and serialize it:



      8, 1, 18, 6, 82, 111, 98, 101, 114, 116, 26, 11, 79, 112, 112, 101, 110, 104, 101, 105, 109, 101, 114, 32, 38 


      As you can see, they are almost the same, but my db send 25 at the start.



      Could you help me, what could be the error?
      Thanks!







      c# protobuf-net






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 26 at 15:29







      Rival Abdrakhmanov

















      asked Mar 25 at 19:05









      Rival AbdrakhmanovRival Abdrakhmanov

      63 bronze badges




      63 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I realized, that it is due to streaming multiple messages.
          And in this case, I've rewritten my method to:



          List<Person> persons;
          using (var responseStream = await response.Content.ReadAsStreamAsync())

          persons = Serializer.DeserializeItems<Person>(responseStream, PrefixStyle.Base128, 0).ToList();






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55344841%2fhow-to-deserialize-protobuf-content-from-httpresponsemessage%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I realized, that it is due to streaming multiple messages.
            And in this case, I've rewritten my method to:



            List<Person> persons;
            using (var responseStream = await response.Content.ReadAsStreamAsync())

            persons = Serializer.DeserializeItems<Person>(responseStream, PrefixStyle.Base128, 0).ToList();






            share|improve this answer



























              0














              I realized, that it is due to streaming multiple messages.
              And in this case, I've rewritten my method to:



              List<Person> persons;
              using (var responseStream = await response.Content.ReadAsStreamAsync())

              persons = Serializer.DeserializeItems<Person>(responseStream, PrefixStyle.Base128, 0).ToList();






              share|improve this answer

























                0












                0








                0







                I realized, that it is due to streaming multiple messages.
                And in this case, I've rewritten my method to:



                List<Person> persons;
                using (var responseStream = await response.Content.ReadAsStreamAsync())

                persons = Serializer.DeserializeItems<Person>(responseStream, PrefixStyle.Base128, 0).ToList();






                share|improve this answer













                I realized, that it is due to streaming multiple messages.
                And in this case, I've rewritten my method to:



                List<Person> persons;
                using (var responseStream = await response.Content.ReadAsStreamAsync())

                persons = Serializer.DeserializeItems<Person>(responseStream, PrefixStyle.Base128, 0).ToList();







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 26 at 15:29









                Rival AbdrakhmanovRival Abdrakhmanov

                63 bronze badges




                63 bronze badges


















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55344841%2fhow-to-deserialize-protobuf-content-from-httpresponsemessage%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript