Re: int not serializable?
From: Joyjit Mukherjee (joyjit_mukherjee_at_hotmail.com)
Date: 08/17/04
- Next message: Stu Smith: "Re: Just In Time Question"
- Previous message: Mohamoss: "RE: Dynamic Enum"
- In reply to: Alexander Wehrli: "int not serializable?"
- Next in thread: Alexander Wehrli: "Re: int not serializable?"
- Reply: Alexander Wehrli: "Re: int not serializable?"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 17 Aug 2004 17:46:11 +0530
Hi,
is the access modifier for the int set to public ? only public fields,
members, properties are serialized & deserialized later.
Regards
Joyjit
"Alexander Wehrli" <AlexanderWehrli@discussions.microsoft.com> wrote in
message news:1EEC3038-9359-4C0E-A815-B2A472DE639C@microsoft.com...
> 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();
- Next message: Stu Smith: "Re: Just In Time Question"
- Previous message: Mohamoss: "RE: Dynamic Enum"
- In reply to: Alexander Wehrli: "int not serializable?"
- Next in thread: Alexander Wehrli: "Re: int not serializable?"
- Reply: Alexander Wehrli: "Re: int not serializable?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|