473,657 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re-implementing ISerializable.G etObjectData() 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.G etObjectData() 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.G etObjectData() 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.G etObjectData()
like:
void System.Runtime. Serialization.I Serializable.Ge tObjectData
(SerializationI nfo info, StreamingContex t context)
This will make sure that this implementation will be seen as the
implementation of ISerializable.G etObjectData(). I do the serialization of
the DataTable in here. Works ok in C#.

The problem is now: I can do something like:
Sub GetObjectData(B yVal info As SerializationIn fo, ByVal context As
StreamingContex t)
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.G etObjectData() 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.G etObjectData() 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 8076
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.G etObjectData. You can then derive from
this class in VB.NET do what you are attempting.

Hope this helps
Jay
"Frans Bouma" <pe************ ******@xs4all.n l> wrote in message
news:Xn******** *************** **********@207. 46.248.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.G etObjectData() 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.G etObjectData() 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.G etObjectData()
like:
void System.Runtime. Serialization.I Serializable.Ge tObjectData
(SerializationI nfo info, StreamingContex t context)
This will make sure that this implementation will be seen as the
implementation of ISerializable.G etObjectData(). I do the serialization of
the DataTable in here. Works ok in C#.

The problem is now: I can do something like:
Sub GetObjectData(B yVal info As SerializationIn fo, ByVal context As
StreamingContex t)
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.G etObjectData() 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.G etObjectData() 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********@ema il.msn.com> wrote in
news:#L******** ******@TK2MSFTN GP11.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.G etObjectData. 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.n l> wrote in message
news:Xn******** *************** **********@207. 46.248.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.G etObjectData() 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.G etObjectData() 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.G etObjectData() like:
void System.Runtime. Serialization.I Serializable.Ge tObjectData
(SerializationI nfo info, StreamingContex t context)
This will make sure that this implementation will be seen as the
implementation of ISerializable.G etObjectData(). I do the serialization
of the DataTable in here. Works ok in C#.

The problem is now: I can do something like:
Sub GetObjectData(B yVal info As SerializationIn fo, ByVal context As
StreamingContex t)
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.G etObjectData() 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.G etObjectData() 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.n l> wrote in message
news:Xn******** *************** **********@207. 46.248.16... "Jay B. Harlow [MVP - Outlook]" <Ja********@ema il.msn.com> wrote in
news:#L******** ******@TK2MSFTN GP11.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.G etObjectData. 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
5253
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 SQL As String = "" End Class Now, i have a proc which given a SQL returns the System.Data.DataTable
2
3824
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 access layer
0
3143
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 datacolumns do not trigger their expression when other columns from which the expressions are derived are updated. Below is a basic example of what I am doing. User enters values into an asp.net form and clicks a button. Retrieve dataset from...
1
2015
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 dataset dsSearch CODE ON http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=3994&lngWId=10 using SQL connection get data from view on sql server, add to dataset dsSearch
5
1669
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 "Shadows" to hide the base class members. However, this does not seem to work. Any pointers as to what I'm doing wrong here? (I've attached the basics of the code below). Thanks Dave Taylor
0
941
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 tried passing it to a "server-side" method using .Net Remoting (even /after/ persuading Remoting to serialise Custom Types). I /sent/ an instance of my /derived/ class, but my server-side component only /received/ a DataTable, with all my extra...
3
1837
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 it to a System.Data.DataSet (a /normal/ one, /not/ a subclass), serialise the whole lot to, say, a file and then deserialise the whole shooting match back into the classes they started with? (All my attempts seem to lose all the Type information...
9
4012
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 DataTable("SliceInfo") Dim tblSliceRatings As New DataTable("SliceRatings") '.... All the adding datacolumns, datarows, etc. goes here.. DatasetInit.Tables.Add(tblSliceInfo)
10
3749
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 datasource. I would like to use an existing class object. The examples I have found state that the class should be in the App_Code folder. However a WAP does not have an App_Code folder. Is there any way to specify a datasource for a local report in a...
1
1972
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 object that contains different data depending on which of MyClass1, MyClass2 are instantiated. I want to be able to iterate through the rows of the data table using For Each on my derived classes retrieving a custom row with properties specific to...
0
8407
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8837
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8612
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7347
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6175
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.