[Mono-dev] Endianess/serialization questions...
Kornél Pál
kornelpal at hotmail.com
Fri Dec 30 18:00:38 EST 2005
Hi,
The serialization infrastructure itself is compatible with MS.NET.
Serialization compatiblity of classes may differ because it depends on their
field layout. If you find such a bug please report it. If you want to make
sure serialization compatiblity across different runtimes and runtime
versions the best thing to do is to serialize only your own classes and use
only basic types and arrays of them as their fields.
Endianness depends on the target architecture. According to CLI specs you
cannot assume endianness. If you want to write endian-safe code use shift
operators (<< and >>) to convert between byte arrays and integers and use
little-endian in files. Note that BinaryReader and BinaryWriter use
little-endian because they use shift operators.
I was unsure about these things before and didn't have a big-endian machine
so I sent some tests to the list and people with big-endian systems helped
me:
Source code for a test:
http://lists.ximian.com/pipermail/mono-devel-list/2005-November/015619.html
Results on a big-endian machine:
http://lists.ximian.com/pipermail/mono-devel-list/2005-November/015620.html
System.BitConverter:
http://lists.ximian.com/pipermail/mono-devel-list/2005-November/015626.html
Kornél
----- Original Message -----
From: "Matthew N. White" <white at bitarmor.com>
To: <mono-devel-list at lists.ximian.com>
Sent: Friday, December 30, 2005 7:33 PM
Subject: [Mono-dev] Endianess/serialization questions...
> Hello all,
>
> I am using mono to run a server application on Linux, and have a few
> questions. First of all, I am talking to the server from different
> machines
> running Microsoft .NET, and am serializing certain objects used between
> the
> two apps and sending them over the network. I have two questions about
> this
> scenario.
>
> First, should I be concerned about serialization problems between mono/MS
> generated serialized objects? Everything appears to be working just fine
> right now, but I just want to be sure.
>
> Secondly, does the virtual machine for .NET/mono actually always use
> big/little endian byte order, or does it depend wholly on the host
> architecture? In other words, would serialized objects be interpretable
> between two machines, one running MS .NET, and the other running mono on a
> big-endian machine (e.g., my server)? Does anyone know if MS .NET runs on
> anything other than little endian machines? Basically, I just want to be
> sure everything will "work" in strange scenarios that may come up, like
> running the server/clients on differing endianess machines.
>
> Does anyone know of any references that would be helpful to answer these
> questions?
>
> Thanks in advance for any help.
>
> Matt
>
>
>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
More information about the Mono-devel-list
mailing list