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;
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
add a comment |
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
add a comment |
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
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
c# protobuf-net
edited Mar 26 at 15:29
Rival Abdrakhmanov
asked Mar 25 at 19:05
Rival AbdrakhmanovRival Abdrakhmanov
63 bronze badges
63 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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();
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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();
add a comment |
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();
add a comment |
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();
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();
answered Mar 26 at 15:29
Rival AbdrakhmanovRival Abdrakhmanov
63 bronze badges
63 bronze badges
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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