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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:15:56+00:00 2026-06-13T23:15:56+00:00

Trying to deserialize an instance of this class [Serializable] public class InstalledMeter : ISerializable

  • 0

Trying to deserialize an instance of this class

[Serializable]
public class InstalledMeter : ISerializable 
{
    public string Description { get; set; }

    public double Latitude { get; set; }
    public double Longitude { get; set; }

    public void GetObjectData(SerializationInfo info, StreamingContext context)
    {
        info.AddValue("Description", Description);
        info.AddValue("Latitude", Latitude);
        info.AddValue("Longitude", Longitude);
    }
}

The instance:

new InstalledMeter {Description = "Something", Latitude = 0.0, Longitude = 0.0};

My Serialization methods

public static class SerializeString
{
    public static string SerializeObject<T>(this T toSerialize)
    {
        var xmlSerializer = new XmlSerializer(toSerialize.GetType());
        var textWriter = new StringWriter();

        xmlSerializer.Serialize(textWriter, toSerialize);
        return textWriter.ToString();
    }

    public static T XmlDeserializeFromString<T>(this string objectData)
    {
        return (T)XmlDeserializeFromString(objectData, typeof(T));
    }

    public static object XmlDeserializeFromString(string objectData, Type type)
    {
        var serializer = new XmlSerializer(type);
        object result;

        using (TextReader reader = new StringReader(objectData))
        {
            result = serializer.Deserialize(reader);
        }

        return result;
    }
}

But when I serialize the object it has these values
enter image description here

  • 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-13T23:15:57+00:00Added an answer on June 13, 2026 at 11:15 pm

    (guessing an answer based on your previous question – Error passing parameters to mvvmcross viewmodels)

    If you are doing this in MvvmCross, then I would avoid this xml problem altogether and just use JSON serialization

      var jsonText = JSONConvert.SerializeObject(installedMeter);
    

    and

      var installedMeter = JSONConvert.DeserializeObject<InstalledMeter>(jsonText);
    

    using just:

        public class InstalledMeter
        {
            public string Description { get; set; }
            public double Latitude { get; set; }
            public double Longitude { get; set; }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to deserialize a JSON string into a class instance in Haxe.
I am trying to deserialize this JSON array into my android project. [{Name:Ban,Price:1},{Name:Banana,Price:1},{Name:chicken,Price:14},{Name:pizza,Price:16},{Name:slice,Price:1}] I
I'm new with JSON.NET and I'm trying to deserialize a JSON string to a
I'm trying to deserialize an XML file like this (it's actually a maven POM
I'm trying to deserialize XML with two namespaces, like this <records xmlns=http://www.foo.com/xml/records/1.1> <record xmlns=http://www.foo.com/xml/record/1.1>
I'm trying deserialize a xml document that looks like this <invoices> <invoice>2848</invoice> <invoice>2849</invoice> <invoice>2850</invoice>
I'm trying to deserialize JSON in this format: { data: [ { installed: 1,
Im trying to deserialize the response from this simple web service Im using the
I have a very simple class that I'm trying to serialize: [ProtoContract] public class
I ve been trying in a few different ways to get XmlSerializer.Deserialize to return

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.