G
Guest
Hi guys
What I am doing:
I'm saving some configuration stuff in an Class called Options. This class
has got some String, bool and an int Member. I Serialize (binary) this object
in a file.
What happens:
If I deserialize the object, all members have got their proper value except
this **** int member! Before serialize this int has got the value 10 and
after derserialize its value is 0. Is int not Serializable? I don't think so:
[Serializable, StructLayout(LayoutKind.Sequential)]
public struct Int32 : IComparable, IFormattable, IConvertible
What am I doing wrong?
Regards Alexander
My Code:
/**derserialization*/
System.IO.Stream s =
System.IO.File.OpenRead(System.Environment.CurrentDirectory+"/trlc.opt");
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter b =
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
Object o = null;
try
{
o= b.Deserialize(s);
}
catch(System.Runtime.Serialization.SerializationException)
{
....
}
if(o != null && o is Options)
{
instance = (Options)o;
}
/**serialization*/
System.IO.Stream s =
System.IO.File.OpenWrite(System.Environment.CurrentDirectory+"/trlc.opt");
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter b =
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
try
{
b.Serialize(s, Options.Instance);
}
catch(System.Runtime.Serialization.SerializationException)
{
....
}
s.Flush();
s.Close();
What I am doing:
I'm saving some configuration stuff in an Class called Options. This class
has got some String, bool and an int Member. I Serialize (binary) this object
in a file.
What happens:
If I deserialize the object, all members have got their proper value except
this **** int member! Before serialize this int has got the value 10 and
after derserialize its value is 0. Is int not Serializable? I don't think so:
[Serializable, StructLayout(LayoutKind.Sequential)]
public struct Int32 : IComparable, IFormattable, IConvertible
What am I doing wrong?
Regards Alexander
My Code:
/**derserialization*/
System.IO.Stream s =
System.IO.File.OpenRead(System.Environment.CurrentDirectory+"/trlc.opt");
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter b =
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
Object o = null;
try
{
o= b.Deserialize(s);
}
catch(System.Runtime.Serialization.SerializationException)
{
....
}
if(o != null && o is Options)
{
instance = (Options)o;
}
/**serialization*/
System.IO.Stream s =
System.IO.File.OpenWrite(System.Environment.CurrentDirectory+"/trlc.opt");
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter b =
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
try
{
b.Serialize(s, Options.Instance);
}
catch(System.Runtime.Serialization.SerializationException)
{
....
}
s.Flush();
s.Close();