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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:10:35+00:00 2026-06-15T02:10:35+00:00

The following code throws error at statement : Result res = (Result)stdserialize.ReadObject(ms); And the

  • 0

The following code throws error at statement :

Result res = (Result)stdserialize.ReadObject(ms);

And the error is : There was an error deserializing the object of type TrackLocation.MainPage+Result. End element ‘types’ from namespace ” expected. Found element ‘item’ from namespace ”.

HttpClient gClientRequest = new HttpClient();
System.Uri gURI = new Uri("http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true");
HttpResponseMessage gResponse = await gClientRequest.GetAsync(gURI);
string   strStream = await gResponse.Content.ReadAsStringAsync();
MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(strStream));
DataContractJsonSerializer stdserialize = new DataContractJsonSerializer(typeof(Result));
Result res = (Result)stdserialize.ReadObject(ms);

//################################################################################################

[DataContract]
public class Address
{
    [DataMember(Name = "long_name")]
    public string address1;
    [DataMember(Name = "short_name")]
    public string shortaddress;
    [DataMember(Name = "formatted_address")]
    public string formattedtaddress;
    [DataMember(Name = "lat")]
    public string latitude;
    [DataMember(Name = "long")]
    public string latitude;
}
//###############################################################################################



[DataContract]
    public class Result
    {           

        [DataMember(Name = "results")]
        public Address[] Results { get; set; }

        [DataMember(Name = "status")]
        public string Status { get; set; }
    }

    [DataContract]
    public class Address
    {
        [DataMember(Name = "formatted_address")]
        public string FormattedAddress;

        [DataMember(Name = "address_components")]
        public AddressComponent[] AddressComponents;
    }

    [DataContract]
    public class AddressComponent
    {
        [DataMember(Name = "long_name")]
        public string LongName;

        [DataMember(Name = "short_name")]
        public string ShortName;

        [DataMember(Name = "types")]
        public string Types;
    }

any idea how to fix this issue.Any help would be greatly appreciated.

  • 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-06-15T02:10:37+00:00Added an answer on June 15, 2026 at 2:10 am

    I just converted the JSON to XMl and found the types to be repeated(check screen shot below) but in your datacontract its
    [DataMember(Name = “types”)]
    public string Types;

    Just put this as

            [DataMember(Name = "types")]
            public string[] Types;
    

    and it should work
    Screen shot

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

Sidebar

Related Questions

The following code throws an compile-time error like Cannot convert type 'string' to 'int'
The following code throws the exception Runtime Error 5: Invalid Procedure Call when the
I am getting null-exception throw error in the following code. What can be the
Argument exception error is thrown at the following code. It's a simple code but
Consider the following code: std::string my_error_string = Some error message; // ... throw std::runtime_error(std::string(Error:
I have following code using hibernate to throw a custom exception on error and
The following code throws System.UriFormatException: var uri = new UriBuilder(ftp://user:pass#word@ftp.somewhere.com:21/fu/bar.zip); System.UriFormatException: Invalid URI: A
The following code throws a TransactionAbortedException with message The transaction has aborted and an
I need to have a checkbox which ajax-submits a form. The following code throws
The following code works fine on Linux but throws an exception on OS X

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.