473,320 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Serialization in Mono

I ran in Mono a program developed on .NET Framework 2.0 and it ran OK
until I tried to desirialize a object. There the program died abruptly
dumping this:

System.ArgumentOutOfRangeException: Value -8590321990885400808 is
outside the valid range [0,3155378975999999999].
Parameter name: ticks
at System.DateTime..ctor (Int64 ticks) [0x00000]
at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.ReadPrimitiv
eTypeValue (System.IO.BinaryReader reader, System.Type type) [0x00000]
at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.ReadValue
(System.IO.BinaryReader reader, System.Object parentObject, Int64
parentObjectId, System.Runtime.Serialization.SerializationInfo info,
System.Type valueType, System.String fieldName,
System.Reflection.MemberInfo memberInfo, System.Int32[] indices)
[0x00000]
at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.ReadObjectCo
ntent (System.IO.BinaryReader reader,
System.Runtime.Serialization.Formatters.Binary.Typ eMetadata metadata,
Int64 objectId, System.Object& objectInstance,
System.Runtime.Serialization.SerializationInfo& info) [0x00000]
at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.ReadObjectIn
stance (System.IO.BinaryReader reader, Boolean isRuntimeObject, Boolean
hasTypeInfo, System.Int64& objectId, System.Object& value,
System.Runtime.Serialization.SerializationInfo& info) [0x00000]
at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.ReadObject
(BinaryElement element, System.IO.BinaryReader reader, System.Int64&
objectId, System.Object& value,
System.Runtime.Serialization.SerializationInfo& info) [0x00000]
at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.ReadNextObje
ct (System.IO.BinaryReader reader) [0x00000]
at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.ReadObjectGr
aph (System.IO.BinaryReader reader, Boolean readHeaders, System.Object&
result, System.Runtime.Remoting.Messaging.Header[]& headers) [0x00000]
at
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.NoCheckDe
serialize (System.IO.Stream serializationStream,
System.Runtime.Remoting.Messaging.HeaderHandler handler) [0x00000]
at
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.Deseriali
ze (System.IO.Stream serializationStream) [0x00000]
at LanguageSystem.WordDisplay.openFileDialog1_FileOk (System.Object
sender, System.ComponentModel.CancelEventArgs e) [0x00000]
at (wrapper delegate-invoke)
System.MulticastDelegate:invoke_void_object_Cancel EventArgs
(object,System.ComponentModel.CancelEventArgs)
at System.Windows.Forms.FileDialog.OnFileOk
(System.ComponentModel.CancelEventArgs e) [0x00000]
at System.Windows.Forms.FileDialog.OnClickOpenSaveBut ton
(System.Object sender, System.EventArgs e) [0x00000]
at System.Windows.Forms.FileDialog.OnForceDialogEndFi leView
(System.Object sender, System.EventArgs e) [0x00000]
at (wrapper delegate-invoke)
System.MulticastDelegate:invoke_void_object_EventA rgs
(object,System.EventArgs)
at System.Windows.Forms.MWFFileView.OnDoubleClick (System.EventArgs e)
[0x00000]
at System.Windows.Forms.ListView+ItemControl.ItemsMou seDown
(System.Object sender, System.Windows.Forms.MouseEventArgs me) [0x00000]
at (wrapper delegate-invoke)
System.MulticastDelegate:invoke_void_object_MouseE ventArgs
(object,System.Windows.Forms.MouseEventArgs)
at System.Windows.Forms.Control.OnMouseDown
(System.Windows.Forms.MouseEventArgs e) [0x00000]
at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message&
m) [0x00000]
at System.Windows.Forms.ListView+ItemControl.WndProc
(System.Windows.Forms.Message& m) [0x00000]
at System.Windows.Forms.Control+ControlNativeWindow.W ndProc
(System.Windows.Forms.Message& m) [0x00000]
at System.Windows.Forms.NativeWindow.WndProc (IntPtr hWnd, Msg msg,
IntPtr wParam, IntPtr lParam) [0x00000]

I've been trying to figure out what went wrong, but I can't see it. Any
ideas?

--
"Now the storm has passed over me
I'm left to drift on a dead calm sea
And watch her forever through the cracks in the beams
Nailed across the doorways of the bedrooms of my dreams"
May 15 '07 #1
5 6086
On Tue, 15 May 2007 17:27:58 +0200, Nikola Skoric <ni*******@net4u.hr>
wrote:

Look at the first error in the hierarchy - all the others just tell
you that one of their subroutines failed.
>System.ArgumentOutOfRangeException: Value -8590321990885400808 is
outside the valid range [0,3155378975999999999].
Parameter name: ticks
at System.DateTime..ctor (Int64 ticks) [0x00000]
It looks llike you have an invalid number of ticks where the app is
trying to reconstruct a DateTime using a constructor with a single
Int64 parameter of the number of ticks.

Check for file corruption, or for an improperly constructed file.

rossum

May 15 '07 #2
On Tue, 15 May 2007 08:27:58 -0700, Nikola Skoric <ni*******@net4u.hr>
wrote:
I ran in Mono a program developed on .NET Framework 2.0 and it ran OK
until I tried to desirialize a object. There the program died abruptly
dumping this:

System.ArgumentOutOfRangeException: Value -8590321990885400808 is
outside the valid range [0,3155378975999999999].
Parameter name: ticks
at System.DateTime..ctor (Int64 ticks) [0x00000]
at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.ReadPrimitiv
eTypeValue (System.IO.BinaryReader reader, System.Type type) [0x00000]
[...]
Well, at first glance it appears to be a signed/unsigned mismatch. But, I
suppose it's also possible that the exception output is incorrectly
formatting the input value and that it's simply a genuine "your number is
too big" exception.

What I would do is take the maximum value described in the range
(3155378975999999999) and set a DateTime object to that to see what actual
date and time that corresponds to. Then look at the input data and see if
you can figure out why it's resulting in a tick count
(-8590321990885400808) that's outside the allowed range.

Somewhere you're reading a date/time value that the Mono version of
DateTime doesn't like. This may be because the Mono DateTime doesn't
handle the same range as the .NET DateTime, it might be because of some
sort of byte-swapping issue (depending on what you're running Mono on), it
might be because of some data structure packing or alignment problem, or
something else entirely. But the first step would be to figure out if the
numbers you're seeing in the exception make any sense (and at first
glance, having a negative number where only positive numbers are allowed
doesn't make sense :) ).

Pete
May 15 '07 #3
In article <op***************@petes-computer.local>,
Np*********@nnowslpianmk.com says...
What I would do is take the maximum value described in the range
(3155378975999999999) and set a DateTime object to that to see what actual
date and time that corresponds to. Then look at the input data and see if
you can figure out why it's resulting in a tick count
(-8590321990885400808) that's outside the allowed range.
Thanks, Pete, you have been very helpful. It turns out that
d = DateTime.FromBinary(3155378975999999999);
Console.WriteLine(d);
returns 31.12.9999 23:59:59. And
d = DateTime.Now;
Console.WriteLine(d.ToBinary());
returns
-8590223521125949343

Now, it seems like Mono and .NET Framework have some big compatibility
issues here...

--
"Now the storm has passed over me
I'm left to drift on a dead calm sea
And watch her forever through the cracks in the beams
Nailed across the doorways of the bedrooms of my dreams"
May 15 '07 #4
On Tue, 15 May 2007 20:55:11 +0200, Nikola Skoric <ni*******@net4u.hr>
wrote:
>In article <op***************@petes-computer.local>,
Np*********@nnowslpianmk.com says...
>What I would do is take the maximum value described in the range
(3155378975999999999) and set a DateTime object to that to see what actual
date and time that corresponds to. Then look at the input data and see if
you can figure out why it's resulting in a tick count
(-8590321990885400808) that's outside the allowed range.

Thanks, Pete, you have been very helpful. It turns out that
d = DateTime.FromBinary(3155378975999999999);
Console.WriteLine(d);
returns 31.12.9999 23:59:59. And
d = DateTime.Now;
Console.WriteLine(d.ToBinary());
returns
-8590223521125949343

Now, it seems like Mono and .NET Framework have some big compatibility
issues here...
You original error messsage talked about "ticks" - the Mono
constructor seemed to need Ticks as input. What does d.Ticks return?
Is that number within the expected range?

The documentation for DateTime mentions both ToBinary() and
FromBinary() to serialize and deserialize a DateTime object. Are you
trying to serialize with ToBinary() and deserialize with a
constructor?

Try deserializing with FromBinary(), that might work better.

rossum
May 15 '07 #5
On Tue, 15 May 2007 13:49:52 -0700, rossum <ro******@coldmail.comwrote:
[...]
The documentation for DateTime mentions both ToBinary() and
FromBinary() to serialize and deserialize a DateTime object. Are you
trying to serialize with ToBinary() and deserialize with a
constructor?

Try deserializing with FromBinary(), that might work better.
Or conversely, serializing with the Ticks property. Though, since you're
serializing to a binary data storage, I'd say the previous suggestion is
probably better (use FromBinary()). Just offering alternatives. :)

Either way, that may well be the problem.

Pete
May 15 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Raseliarison nirinA | last post by:
hi all, i found an unanswered question at http://www.faqts.com/knowledge_base/index.phtml/fid/538 with possible response below. i've tried to send it at faqt.python but can't figure out how to...
11
by: Tony Baker | last post by:
In order for my company to go ahead and use .Net and C# (over java), I need to know how to install and run a C# ASP.Net application not only on Windows, but on Linux. I'm a Windows developer,...
5
by: fliversen | last post by:
Hello, does anyone have successfull experience with mono on Windows. I have download mono-1.0.1-gtksharp-1.0-win32-0.5.exe But to compile und run programs whitch use Gtk# is not possible:...
0
by: John Bailo | last post by:
http://www.onlamp.com/pub/wlg/7468 "Mono Live was released on May 24, 2005. Although there are several Live Linux CDs with Mono, they are all based on Knoppix and use KDE as the default Linux...
2
by: Mike Schilling | last post by:
Is there an official specification for .NET serialization? I've looked at the .NET framework docs and read Jeffrey Richter's MSDN articles, but I'm looking for something more complete,...
1
by: Silesian | last post by:
I realize that this is a newbie question but maybe someone will be able to tell me what am I doing wrong. createFile() gets called each time I have the user generate some numbers which then get...
1
by: Joannes Vermorel | last post by:
I am having a serialization problem with a simple piece of code (short & complete) available at http://www.vermorel.com/opensource/NGridBugDemo.cs . When I run this code, I get a...
6
by: Twig | last post by:
Hi, Can I use strictly for C# development without missing anything from MS? Twig
2
by: flagos | last post by:
Hi to all! Any of you know if it's possible to use the Cairo graphics library in a WIN32 c# application? I know there is a binding made for Mono but my app will run on win32 so obviously I wont...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.