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

Re-implementing ISerializable.GetObjectData() on DataTable derived class

Hi,

I have a serious problem with VB.NET and a DataTable derived class and I
can't figure out how to solve it. I have implemented it in C# where it
works perfectly, but I can't port one statement to VB.NET and this is
crucial: re-implementing ISerializable.GetObjectData() in the DataTable
derived class so serializing the datatable derived class will call this
method and not the DataTable version (which is private, so overriding is
also not possible)

It comes down to this:
1) I have a DataTable derived class. This class is implemented in VB.NET.
This class contains a private member.
2) I want to serialize and deserialize this class using Soap or Binary
formatter. The problem is the private member variable: because of this I
have to implement ISerializable.GetObjectData() because DataTable already
implements this method, but this method is Private, and if I don't
implement this method I can't serialize this membervariable because the
DataTable's GetObjectData() method will be called instead.
3) In C# I can solve this by re-implementing ISerializable.GetObjectData()
like:
void System.Runtime.Serialization.ISerializable.GetObje ctData
(SerializationInfo info, StreamingContext context)
This will make sure that this implementation will be seen as the
implementation of ISerializable.GetObjectData(). I do the serialization of
the DataTable in here. Works ok in C#.

The problem is now: I can do something like:
Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As
StreamingContext)
in VB.NET but that will not help me, because when serializing, this method
will not be called, simply because it is not seen as a
ISerializable.GetObjectData() implementation, so the DataTable version is
used, which is not what I want, because of the private member variable.

I also can't specify Implements ISerializable.GetObjectData() or other
ways to make sure this is a re-implementation of the interface member,
because the VB.NET compiler will then throw an error saying that the base
class already implements this interface and/or method.

My question is now: Is it possible to solve this in VB.NET? I couldn't
find any information which states how to re-implement interface members,
but perhaps I'm overlooking something.

Thanks in advance!

FB

--
Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com
Nov 20 '05 #1
3 8047
Frans,
What you have stated is the way I understand VB.NET works, Once a class
implements an interface, base classes cannot re-implement them.

If you really need to do this, I would recommend a C# base class that you
use to "re-implement" ISerializable.GetObjectData. You can then derive from
this class in VB.NET do what you are attempting.

Hope this helps
Jay
"Frans Bouma" <pe******************@xs4all.nl> wrote in message
news:Xn*********************************@207.46.24 8.16...
Hi,

I have a serious problem with VB.NET and a DataTable derived class and I
can't figure out how to solve it. I have implemented it in C# where it
works perfectly, but I can't port one statement to VB.NET and this is
crucial: re-implementing ISerializable.GetObjectData() in the DataTable
derived class so serializing the datatable derived class will call this
method and not the DataTable version (which is private, so overriding is
also not possible)

It comes down to this:
1) I have a DataTable derived class. This class is implemented in VB.NET.
This class contains a private member.
2) I want to serialize and deserialize this class using Soap or Binary
formatter. The problem is the private member variable: because of this I
have to implement ISerializable.GetObjectData() because DataTable already
implements this method, but this method is Private, and if I don't
implement this method I can't serialize this membervariable because the
DataTable's GetObjectData() method will be called instead.
3) In C# I can solve this by re-implementing ISerializable.GetObjectData()
like:
void System.Runtime.Serialization.ISerializable.GetObje ctData
(SerializationInfo info, StreamingContext context)
This will make sure that this implementation will be seen as the
implementation of ISerializable.GetObjectData(). I do the serialization of
the DataTable in here. Works ok in C#.

The problem is now: I can do something like:
Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As
StreamingContext)
in VB.NET but that will not help me, because when serializing, this method
will not be called, simply because it is not seen as a
ISerializable.GetObjectData() implementation, so the DataTable version is
used, which is not what I want, because of the private member variable.

I also can't specify Implements ISerializable.GetObjectData() or other
ways to make sure this is a re-implementation of the interface member,
because the VB.NET compiler will then throw an error saying that the base
class already implements this interface and/or method.

My question is now: Is it possible to solve this in VB.NET? I couldn't
find any information which states how to re-implement interface members,
but perhaps I'm overlooking something.

Thanks in advance!

FB

--
Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com

Nov 20 '05 #2
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in
news:#L**************@TK2MSFTNGP11.phx.gbl:
Frans,
What you have stated is the way I understand VB.NET works, Once a class
implements an interface, base classes cannot re-implement them.
I was afraid of that... :(
If you really need to do this, I would recommend a C# base class that
you use to "re-implement" ISerializable.GetObjectData. You can then
derive from this class in VB.NET do what you are attempting.
I think that's the only solution to this indeed. Requires some
refactoring though ... :/ I hope VB.NET's designers will solve this in
Whidbey.

Thanks for the info.

FB

Hope this helps
Jay
"Frans Bouma" <pe******************@xs4all.nl> wrote in message
news:Xn*********************************@207.46.24 8.16...
Hi,

I have a serious problem with VB.NET and a DataTable derived class and
I can't figure out how to solve it. I have implemented it in C# where
it works perfectly, but I can't port one statement to VB.NET and this
is crucial: re-implementing ISerializable.GetObjectData() in the
DataTable derived class so serializing the datatable derived class will
call this method and not the DataTable version (which is private, so
overriding is also not possible)

It comes down to this:
1) I have a DataTable derived class. This class is implemented in
VB.NET. This class contains a private member.
2) I want to serialize and deserialize this class using Soap or Binary
formatter. The problem is the private member variable: because of this
I have to implement ISerializable.GetObjectData() because DataTable
already implements this method, but this method is Private, and if I
don't implement this method I can't serialize this membervariable
because the DataTable's GetObjectData() method will be called instead.
3) In C# I can solve this by re-implementing
ISerializable.GetObjectData() like:
void System.Runtime.Serialization.ISerializable.GetObje ctData
(SerializationInfo info, StreamingContext context)
This will make sure that this implementation will be seen as the
implementation of ISerializable.GetObjectData(). I do the serialization
of the DataTable in here. Works ok in C#.

The problem is now: I can do something like:
Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As
StreamingContext)
in VB.NET but that will not help me, because when serializing, this
method will not be called, simply because it is not seen as a
ISerializable.GetObjectData() implementation, so the DataTable version
is used, which is not what I want, because of the private member
variable.

I also can't specify Implements ISerializable.GetObjectData() or other
ways to make sure this is a re-implementation of the interface member,
because the VB.NET compiler will then throw an error saying that the
base class already implements this interface and/or method.

My question is now: Is it possible to solve this in VB.NET? I couldn't
find any information which states how to re-implement interface
members, but perhaps I'm overlooking something.

Thanks in advance!

FB

--
Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com



--
Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com
Nov 20 '05 #3
Frans,
I hope VB.NET's designers will solve this in
Whidbey. I'm not so sure VB.NET is "broken" per se here.

You could always submit an MS Wish to have the current behavior changed.

http://register.microsoft.com/mswish/suggestion.asp

Jay

"Frans Bouma" <pe******************@xs4all.nl> wrote in message
news:Xn*********************************@207.46.24 8.16... "Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in
news:#L**************@TK2MSFTNGP11.phx.gbl:
Frans,
What you have stated is the way I understand VB.NET works, Once a class
implements an interface, base classes cannot re-implement them.


I was afraid of that... :(
If you really need to do this, I would recommend a C# base class that
you use to "re-implement" ISerializable.GetObjectData. You can then
derive from this class in VB.NET do what you are attempting.


I think that's the only solution to this indeed. Requires some
refactoring though ... :/ I hope VB.NET's designers will solve this in
Whidbey.

Thanks for the info.

FB

Hope this helps
Jay

<<snip>>
Nov 20 '05 #4

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

Similar topics

5
by: Eidolon | last post by:
I have a class which inherits from System.Data.DataTable. The code is basically (property procs omitted for clarity): Public Class DataTable() Inherits System.Data.DataTable Public Property...
2
by: DC | last post by:
I have created the following abstract class: public abstract class BaseC { protected int _ID; protected string _name; protected abstract DataTable GetData(int ID); // intended to hit data...
0
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these...
1
by: cindy | last post by:
Get data into datatable, add to dataset dsSearch " Get data into datatable, add to dataset dsSearch Using In-Memory SQL Engine join the tables and select the filenames from the join, add to...
5
by: Dave Taylor | last post by:
I'm trying to derive a class from a typed DataSet to add some methods to one of the DataTables. I would like to keep the names the same in the derived class as in the base class, so I have used...
0
by: Phill W. | last post by:
Can VB2005 /correctly/ pass a class derived from Datatable via .Net Remoting? Using VB2003, I created a class inherited from DataTable and added some extra bits to it. All was well until I...
3
by: Phill W. | last post by:
OK, I've asked nicely before; now I'm going to throw down the gauntlet to anyone brave enough to take it up. In VB'2005, can anyone write me a class that inherits from System.Data.DataTable, add...
9
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New...
10
by: AG | last post by:
I am trying to use a ReportViewer control in a VS 2005 web application project (not Website project). When I try to create a new report (local), I can't seem to find any method to create a...
1
by: Charles Law | last post by:
I have a base class MyBaseClass, and several classes that inherit from it: MyClass1, MyClass2, etc. The base class implements IEnumerable(Of IMyBaseClassRow). The base class has a DataTable...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.