473,322 Members | 1,314 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,322 software developers and data experts.

Serialization problem with DataTable

we are having a problem when trying to serilalize and deserialize DataTable
When replacing the container to be ListArray or HashTable everything works
fine

The code is very straight forward ( see below), however when comparing the
DataTable before and after the serialize, it is not the same
The DataTable after the serialization contains only the string of class type
( Vclass in this class) but not the class itself

Any idea ?
David

-----

Dim bfx As New Runtime.Serialization.Formatters.Binary.BinaryForm atter

Dim _streamx As New IO.MemoryStream

Dim vidSrc As New VClass(999, 1)

Dim dtSrc As New DataTable

dtSrc.Columns.Add("vid", GetType(VClass))

Dim newRow As DataRow = dtSrc.NewRow()

newRow("vid") = vidSrc

dtSrc.Rows.Add(newRow)

bfx.Serialize(_streamx, dtSrc)

_streamx.Position = 0

Dim dtDest As DataTable = bfx.Deserialize(_streamx)

Where VClass is as follows:

<Serializable()> Public Class VClass

Implements Runtime.Serialization.ISerializable

Protected m_id As Integer

Protected m_owner As Integer

'Serialization function.

Public Sub New()

MyBase.new()

m_id = -1

m_owner = 1

End Sub

Public Sub New(ByVal id As Integer, ByVal owner As Integer)

MyBase.new()

m_id = id

m_owner = owner

End Sub

'copy CTOr

Public Sub New(ByVal other As VClass)

MyBase.new()

m_id = other.m_id

m_owner = other.m_owner

End Sub

Protected Sub New(ByVal info As Runtime.Serialization.SerializationInfo,
ByVal context As Runtime.Serialization.StreamingContext)

m_id = CInt(info.GetValue("m_id", GetType(Integer)))

m_owner = CInt(info.GetValue("m_owner", GetType(Integer)))

End Sub 'New

Public Sub GetObjectData(ByVal info As
Runtime.Serialization.SerializationInfo, ByVal context As
Runtime.Serialization.StreamingContext) Implements
Runtime.Serialization.ISerializable.GetObjectData

info.AddValue("m_id", m_id)

info.AddValue("m_owner", m_owner)

End Sub 'GetObjectData
Jul 21 '05 #1
4 2062
Hi David,

Thanks for your post. I reproduced the problem with your code, and I am
performing further research on this issue.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #2
Hello David,

I discussed this issue with an expert on ADO .NET, we found that
custom-typed columns serialization is not curerntly supported by the .NET
Framework. The custom deserialization constructor and GetObjecData methods
wouldn't be called so you never get the member data in the output stream.
Instead, the type name (columnitem.ToString()) is written to the stream.
During deserialization, the type name is read back so you get the type
"System.String".

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #3
What do you mean does not supported in the .NET Framework?
if I use a HashTable or array list it works great ( which both are .NET
framework classes)
if it is not supported it should be well documented - currently the
documentation said that this class implement ISerializable
which lead you to think it support custom type columns.
Since it is not the first time we encounter with such undocumented caveats I
want to emphasize the importance of documenting those caveats to increase
the efficient of developers using .NET framework

David
"Tian Min Huang" <ti******@online.microsoft.com> wrote in message
news:Ir**************@cpmsftngxa06.phx.gbl...
Hello David,

I discussed this issue with an expert on ADO .NET, we found that
custom-typed columns serialization is not curerntly supported by the .NET
Framework. The custom deserialization constructor and GetObjecData methods
wouldn't be called so you never get the member data in the output stream.
Instead, the type name (columnitem.ToString()) is written to the stream.
During deserialization, the type name is read back so you get the type
"System.String".

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #4
Hello David,

Thanks a lot for your feedback. I consulted our Developer Team and the
DataColumn supports the base .NET Framework data types (as documented in
the MSDN article below) serialization/deserialization, while it treat other
class types as string.

DataColumn.DataType Property
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemdatadatacolumnclassdatatypetopic.asp

Please feel free to let me know if you have any concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #5

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

Similar topics

0
by: Orly Junior | last post by:
Gentlemen, I am working with .Net Remoting, but I am running into many problems. Probably due to the fact that I am not very experienced with that new technology. The question is... after...
0
by: Stephan Moeller | last post by:
Hi NG, I serialize the following class over .net remoting: using System; using System.Collections; namespace JobServerLib {
4
by: hs | last post by:
Hi I am serializing a dataset using a binary formatter as follows: IFormatter formater = new BinaryFormatter(); formatter.Serialize(stream, ds); // ds=DataSet, stream=MemoryStream .... DataSet...
4
by: Brian Keating | last post by:
wonder if anyone can help me here, i've a framework 1.1 dataset which i serialize in framework 1.1 and deserialize in framework 2.0. This is fine, problem is that i want to modify some of the...
1
by: elziko | last post by:
My intention is to store an array of singles inside a DataTable so that it can me peristed somehow, maybe XML file, maybe Access/SQL Server I don't know yet so I'm just saving it as an XML file for...
4
by: David K | last post by:
we are having a problem when trying to serilalize and deserialize DataTable When replacing the container to be ListArray or HashTable everything works fine The code is very straight forward (...
5
by: Henry Jones | last post by:
I read a bit on Serialization and came up with the following definition: The System.Runtime.Serialization namespace contains classes that can be used for serializing and deserializing objects....
0
by: Igor | last post by:
Hi everyone ! I have a problem with object serialization. I created web service with number of methods. One of them receives object of the next type: public class ObjectClass private szValue...
2
by: sylvain.ross | last post by:
Hello everybody, I have a very weird problem regarding the serialization of a class that I wrote (named DummyClass in my exemple). My class inherits from DataTable. Then I just try a dummy...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
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...
1
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.