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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:51:50+00:00 2026-05-26T10:51:50+00:00

I am trying to fetch data from my .net project on my android device.

  • 0

I am trying to fetch data from my .net project on my android device.

On the android I am using this code:

    DefaultHttpClient client = new DefaultHttpClient();
    HttpGet request = new HttpGet("http://192.168.0.100/protobufnet/Default.aspx"); 

    HttpResponse response;
    response = client.execute(request);
    DataPacket.Data data = DataPacket.Data.parseFrom(response.getEntity().getContent());

The DataPacket.Data have been autogenerated from my .proto file that i wrote by hand and looks like this

message Data {
required int32 Status = 1;
message Building {
    required string Id = 1;
    optional string Name = 2;
    optional string Description = 3;
    message RentSpace {
        required string Id = 1;
        optional string Name = 2;
        optional string Description = 3;            
        message Year {
            required int32 Year = 1;
            message Item {
                required string Id = 1;
                optional string Name = 2;
                optional string Description = 3;        
                optional string FunctionDescription = 4;        
                required bool Marked = 5;
                required bool Remark = 6;
                required bool SelfLearning = 7;
                optional string Comment = 8;
                repeated bool ActiveMonths = 9 [packed=true];
            }
            repeated Item Items = 2;
        }
        repeated Year Years = 4;
    }
    repeated RentSpace RentSpaces = 4;
}
repeated Building Buildings = 4;

}

Now I dont know how to make my .net project validate against this .proto file, So I just coded what I assumed would be the same like this:

[ProtoContract]
public class DataPacket
{
    [ProtoMember(1)]
    public int Status { get; set; }
    [ProtoMember(2)]
    public List<Building> Buildings { get; set; }
}

[ProtoContract]
public class Building
{
    [ProtoMember(1)]
    public String Id {get;set;}
    [ProtoMember(2)]
    public String Name {get;set;}
    [ProtoMember(3)]
    public String Description {get;set;}
    [ProtoMember(4)]
    public List<RentSpace> RentSpaces { get; set; }
}

[ProtoContract]
public class RentSpace
{
    [ProtoMember(1)]
    public String Id {get;set;}
    [ProtoMember(2)]
    public String Name {get;set;}
    [ProtoMember(3)]
    public String Description {get;set;}
    [ProtoMember(4)]
    public List<YearList> Years {get;set;}
}

[ProtoContract]
public class YearList
{
    [ProtoMember(1)]
    public int Year;
    [ProtoMember(2)]
    public List<ListItem> Items {get;set;}
}

[ProtoContract]
public class ListItem
{
    [ProtoMember(1)]
    public String Id {get;set;}
    [ProtoMember(2)]
    public String Name {get;set;}
    [ProtoMember(3)]
    public String Description {get;set;}
    [ProtoMember(4)]
    public String FunctionDescription { get; set; } //how to do the control

    [ProtoMember(5)]
    public bool Marked { get; set; }
    [ProtoMember(6)]
    public bool Remark { get; set; }
    [ProtoMember(7)]
    public bool SelfLearning { get; set; }
    [ProtoMember(8)]
    public string Comment { get; set; }
    [ProtoMember(9)]
    public bool[] ActiveMonths { get; set; }

But it is not working. I either need to see the .proto the .net project uses or force it to validate against my .proto

  • 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-26T10:51:50+00:00Added an answer on May 26, 2026 at 10:51 am

    The v1 zip of protobuf-net includes a tool “protogen” that is basically protobuf-net’s “protoc” (actually it uses protoc internally for some of the steps, hence the size). This tool is unchanged in v2, and is fine to use alongside the v2 library.

    If you are usig Visual Studio there is also an IDE tool to do the same thing inside the tooling – i.e. you just add your .proto to a project, and it will generate the matching c# for you.

    It is also fully possible to create the type-model manually – I would need to sit down and look very carefully to see the differences between your .proto and your c# (of course, being a bit more specific than “But it is not working” would help, too).

    The other obvious thing to check, of course, is that you got the right byte in your (separate) transfer code.

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

Sidebar

Related Questions

I'm trying to fetch data from a div (based on his id), using PHP's
I'm using an Oracle DB and I'm trying to fetch data from its tables
I am trying to fetch data from DBF files from a .NET REST service.
I'm trying to fetch some data from a column whose DATA_TYPE=NUMBER(1,0) with this piece
I'm trying to fetch some settings from my membership provider in my asp.net application
I am trying to fetch data from DB and loading the DB with the
I am doing a cross-domain fetch from a ASP.NET page using Jquery-JSONP My ASP.NET
I am trying to fetch data from my database and when I display it
I'm was trying a tutorial to get data to android from a MySQL database
I am new in Android. I am trying to make an RPC to fetch

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.