Updated Serialized Class

S

senfo

Originally, I had a class like the following that I would serialize to
persist values from an options dialog:

[Serializable()]
public class MyClass
{
private int _someNum;
private string _someString;

public int SomeNum
{
get { return _someNum; }
set { _someNum = value; }
}

public int SomeString
{
get { return _someString; }
set { _someString = value; }
}
}

I later added a boolean type to the class as such:

[Serializable()]
public class MyClass
{
private int _someNum;
private string _someString;
private bool _someBool

public int SomeNum
{
get { return _someNum; }
set { _someNum = value; }
}

public string SomeString
{
get { return _someString; }
set { _someString = value; }
}

public bool SomeBool
{
get { return _someBool; }
set { _someString = someBool; }
}
}

Clients already have the original configuration class serialized on
their machines and now I need to ensure that, when the updated
application is installed, the value of SomeBool is true, by default.

Without deleting the original configuration file, is there any way that
I can ensure that the value of SomeBool is set to true? After the
update, it would be a little silly to ask that the users open their
options dialog to verify that the CheckBox is checked. ;-)

Thank you in advance,
 
S

senfo

senfo said:
By the way, in hindsight, yes, I should have used settings
(http://msdn2.microsoft.com/en-us/library/aa730869(vs.80,d=printer).aspx).
I still might migrate the code, but I'm kind of in crunch mode right now!

Well never mind...I ended up migrating all my code to use Settings and I
must say that it was quite painless (mainly because the custom
architecture I designed was almost identical to the one in .NET (at
least when you ignore the implementation)).

Thank you,
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

senfo said:
Well never mind...I ended up migrating all my code to use Settings and I
must say that it was quite painless (mainly because the custom
architecture I designed was almost identical to the one in .NET (at
least when you ignore the implementation)).

There are a good reason why serialization is usually not
recommended for long term persistence.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top