[Mono-dev] Endianess/serialization questions...
kornelpal at hotmail.com
Fri Dec 30 18:00:38 EST 2005
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
Source code for a test:
Results on a big-endian machine:
----- 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
> running Microsoft .NET, and am serializing certain objects used between
> two apps and sending them over the network. I have two questions about
> 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
> Thanks in advance for any help.
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
More information about the Mono-devel-list