Re: int not serializable?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Joyjit Mukherjee (joyjit_mukherjee_at_hotmail.com)
Date: 08/17/04


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();



Relevant Pages

  • Re: int not serializable?
    ... only public fields,>> members, properties are serialized & deserialized later. ... bool and an int Member. ... I Serialize this>> object ... >>> Regards Alexander ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: CryptRL 0.6340 first ASCII release
    ... taken more personally than general game comments. ... which has over 300 public members. ... int getDexterite() ... void setDexterite_Mod ...
    (rec.games.roguelike.development)
  • Re: CryptRL 0.6340 first ASCII release
    ... taken more personally than general game comments. ... int getDexterite() ... void setDexterite_Mod ... These 12 members can be replaced with just a few: ...
    (rec.games.roguelike.development)
  • Re: Storing Users/Groups
    ... websites can interface with this setup. ... > returns @outtable table (root_node int, group_key int, primary key ... > --40 members are members of 50 ... PRIMARY KEY, ...
    (microsoft.public.sqlserver.programming)
  • Re: A question in the objects size.
    ... > int id; ... > String name; ... then the order in which the base and derived members occur could ... leeway in deciding how to arrange the member variables. ...
    (comp.lang.java.programmer)