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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:00:16+00:00 2026-05-26T07:00:16+00:00

I’m working to an iPhone project using MonoTouch, and I need to serialize and

  • 0

I’m working to an iPhone project using MonoTouch, and I need to serialize and save a simple object belonging to a c# class with a CLLocation type as data member:

[Serializable]
public class MyClass
{
    public MyClass (CLLocation gps_location, string location_name)
    {
        this.gps_location = gps_location;
        this.location_name = location_name;
    }

    public string location_name;
    public CLLocation gps_location;
}

This is my binary serialization method:

static void SaveAsBinaryFormat (object objGraph, string fileName)
    {
        BinaryFormatter binFormat = new BinaryFormatter ();
        using (Stream fStream = new FileStream (fileName, FileMode.Create, FileAccess.Write, FileShare.None)) {
            binFormat.Serialize (fStream, objGraph);
            fStream.Close ();
        }
    }

But when I execute this code (myObject is an instance of the above class):

try {
            SaveAsBinaryFormat (myObject, filePath);
            Console.WriteLine ("object Saved");
        } catch (Exception ex) {
            Console.WriteLine ("ERROR: " + ex.Message);
        }

I get this exception:

ERROR: Type MonoTouch.CoreLocation.CLLocation is not marked as Serializable.

Is there a way to serialize a class with CLLocation?

  • 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-26T07:00:17+00:00Added an answer on May 26, 2026 at 7:00 am

    Since a class is not marked with the SerializableAttribute, it cannot be serialized. However, with a bit of extra work, you can store the information you need from it and serialize it, at the same time keeping it in your object.

    You do this by creating a property for it, with the appropriate backing stores, depending on the information you want from it. For example, if I only want the coordinates of the CLLocation object, I would create the following:

    [Serializable()]
    public class MyObject
    {
    
        private double longitude;
        private double latitude;
        [NonSerialized()] // this is needed for this field, so you won't get the exception
        private CLLocation pLocation; // this is for not having to create a new instance every time
    
        // properties are ok    
        public CLLocation Location
        {
            get
            {
                if (this.pLocation == null)
                {
                    this.pLocation = new CLLocation(this.latitude, this.longitude);
                }
                return this.pLocation;
    
            } set
            {
                this.pLocation = null;
                this.longitude = value.Coordinate.Longitude;
                this.latitude = value.Coordinate.Latitude;
            }
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I am doing a simple coin flipping experiment for class that involves flipping a
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.