HighTechTalks DotNet Forums  

Datetime DbNull values in Dataset not deserialized correctly when RemotingFormat is set to Binary

Dotnet Framework (Remoting) microsoft.public.dotnet.framework.remoting


Discuss Datetime DbNull values in Dataset not deserialized correctly when RemotingFormat is set to Binary in the Dotnet Framework (Remoting) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
pepemsk@gmail.com
 
Posts: n/a

Default Datetime DbNull values in Dataset not deserialized correctly when RemotingFormat is set to Binary - 11-02-2006 , 11:16 AM






Hi,

when using BinaryFormatter to serialize and deserialize a DataSet that
has RemotingFormat set to SerializationFormat.Binary, all the DateTime
fields that have DBNull value are changed to 01.01.0001 01:00
(DateTime.MinValue). This does not happed when the RemotingFormat is
not Binary.

I believe this is a bug - the deserialized object is not the same as
the original.

Also, it is impossible to store such corrupted dataset to a database,
01.01.0001 value causes an overflow exception in the SqlDateTime value.

The binary (de)serialization is much faster than the 'xml'
(de)serialization, we would like to use it, but we do not want to
repair every datetime value in every row of every table after the
dataset has been transfered through remoting or loaded from a file.

Please, does anyone know a workaround for this ?
Thank you!

Peter

Example:
// DataSet2 is a simple one table dataset.
// The DataTable1 table contains only one DateTime field that
// is DBNull by default.

// Add a test row
DataSet2 ds = new DataSet2();
DataSet2.DataTable1Row row = ds.DataTable1.NewDataTable1Row();
ds.DataTable1.AddDataTable1Row(row);

// Use binary format
ds.RemotingFormat = SerializationFormat.Binary;

// Serialize
// Now the value of DateTime field in DataTable1 is DBNull

MemoryStream ms = new MemoryStream();

BinaryFormatter fmt = new BinaryFormatter();
fmt.Serialize(ms, ds);

ms.Flush();
ms.Seek(0, SeekOrigin.Begin);

// Deserialize
DataSet2 ds2 = (DataSet2)fmt.Deserialize(ms);

ms.Close();

// At the end the value of DateTime field in DataTable1 is 01/01/0001
01:00 (DateTime.MinValue)


Reply With Quote
  #2  
Old   
pepemsk@gmail.com
 
Posts: n/a

Default Re: Datetime DbNull values in Dataset not deserialized correctly when RemotingFormat is set to Binary - 11-03-2006 , 09:48 AM






There probably is no remedy. I am going to use some replacement for
BinaryFormatter.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.