473,397 Members | 2,077 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,397 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 2068
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.