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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:43:19+00:00 2026-06-17T04:43:19+00:00

In my WP8 app I have a special type of ‘settings’ objects that are

  • 0

In my WP8 app I have a special type of ‘settings’ objects that are stored in IsolatedStorageSettings.ApplicationSettings. These objects set some initial state in their constructors and that state may be changed later.

Now the problem is that apparently when object is deserialized it’s constructor gets called again, thus resetting changes in state and it is not what I want.

Basically something like this:

class Test
{
    public int a { get; set; }
    public Test() { a = 1; }
}

Test x = new Test();
x.a = 2;

IsolatedStorageSettings.ApplicationSettings["test"] = x;
IsolatedStorageSettings.ApplicationSettings.Save();

// on next app launch
Test x = IsolatedStorageSettings.ApplicationSettings["test"] as Test;
Debug.writeLine(x.a) // 1, I want 2

Can I change the process somehow so that object’s constructor will not be called on deserialization?

  • 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-17T04:43:20+00:00Added an answer on June 17, 2026 at 4:43 am

    Of course a deserializer has to call the type’s constructor, because it needs to first create an instance of a type (the object) and then fill the object’s properties with the data found in the serialized input.

    So, a quick workaround is to leave the default parameterless constructor blank, and do your special init’s in a constructor with a parameter or with a dedicated call to a method to initialize your object.

    OR, use a dedicated type for serializing/deserializing, a DTO (Data Transfer Object) and then use from that object whatever information you need.


    But anyway, something is fishy, in your code sample, it should work as you expect because first the deserializer would call the constructor and only after that set the properties, you can test this by setting breakpoints in the class constructor and in the setters of individual properties to see the process workflow.

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

Sidebar

Related Questions

I read that Windows wp8 allows native code. So how then have ports such
I have a Windows Phone app build using the 7.1 SDK that works great
I'm working on a WP8 app that uses a ScheduledTaskAgent to update a Live
after trying to start my first WP8 App I got an error saying that
I have a database from an existing android app that I need to import
So, I have created a (C#) WP7 app that doesn't have too much complicated
I want to potentially update the tile of my WP8 app periodically - no
I have a C++ runtime component in a WP8 application, and if I change
On WP 7 and WP 7.5 I have to develop the app on C#,
I want to create a windows phone 8 app that allows the user to

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.