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

VB.NET 2003 - Inheritance issue

Hello,

I am building a project using VB.NET and the .NET framework with VS.NET
2003. I am having a problem with a derived class that I can not understand.
I have a base class in a class library written in C# and I need a derived
class in my VB.NET application. The problem is that my derived method is not
being called, only the base class method in the library. I have overriden
the constructor and that works. Here is a skeleton of my code:

In C# library is this function, the class is itself derived from the Stream
class:

public override int Read(byte[] buf, int ofs, int count)

{

int toread = (int)Math.Min(count, m_Length - Position);

return Stream.Read(buf, ofs, toread);

}

In my VB.NET code:

Public Overrides Function Read(ByVal Buffer() As Byte, ByVal iOffset As
Integer, ByVal iCount As Integer) As Integer

Dim iBytesRead As Integer = MyBase.read(Buffer, iOffset, iCount)

If iBytesRead < iCount Then

'

' End of file

'

mEndOfFile = True

End If

Return iBytesRead

End Function

The VB method is not called. As I mentioned the overidden "New" is called.

Sid.
Dec 29 '05 #1
2 930
>The VB method is not called.

Can you also post the code where you create an instance of the class
and call Read?

As I mentioned the overidden "New" is called.


Constructors are never inherited and therefore not overridable.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Dec 29 '05 #2
HI,

The object is instantiated with:

mStream = New AudioStream(strFilename)

AudioStream is teh derived class.

The Read method is called by the following line:

mBuffer.Write(mNextWritePos, mStream, iBytesToPush, LockFlag.None)
The mBuffer variable is a DirectX secondary buffer and the mStream parameter
is stream to "pull" data from. The "Read" method called by this line is in
the base class of mStream NOT mStream itself.

Sid.

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:uv**************@tk2msftngp13.phx.gbl...
The VB method is not called.


Can you also post the code where you create an instance of the class
and call Read?

As I mentioned the overidden "New" is called.


Constructors are never inherited and therefore not overridable.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Dec 29 '05 #3

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

Similar topics

11
by: Ricky Romaya | last post by:
Hi, Are there any ways to get multiple inheritace in PHP4? For example, I have 3 parent class, class A, B, and C. I want class X to inherit all those 3 classes. Consider merging those 3 classes...
4
by: JKop | last post by:
I'm starting to think that whenever you derive one class from another, that you should use virtual inheritance *all* the time, unless you have an explicit reason not to. I'm even thinking that...
14
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
15
by: Sinex | last post by:
Hi, Why does C# disallow multiple inheritance? Whats the reason behind this? Is there any advantage or is it just a method to avoid some problems (if so, what problems?) that come with multiple...
45
by: Ben Blank | last post by:
I'm writing a family of classes which all inherit most of their methods and code (including constructors) from a single base class. When attempting to instance one of the derived classes using...
6
by: VR | last post by:
Hi, I read about Master Pages in ASP.Net 2.0 and after implementing some WinForms Visual Inheritance I tryed it with WebForms (let's say .aspx pages, my MasterPage does not have a form tag itself...
11
by: PAul Maskens | last post by:
The form designer adds unnecessary code to the section when using a subclassed control. I've reproduced this in VS.NET 2002 and VS.NET 2003 so it's pretty fundamental. Outline steps: Create a...
1
by: Dan Munk | last post by:
Hello, I have a large project exclusively made up of interfaces (several hundred) that define the business objects used in our system. Heavy inheritance and aggregation are used in the project....
16
by: devicerandom | last post by:
Hi, I am currently using the Cmd module for a mixed cli+gui application. I am starting to refactor my code and it would be highly desirable if many commands could be built as simple plugins. ...
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
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...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.