472,969 Members | 1,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,969 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 8017
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.