VB.NET 2003 - Inheritance issue

G

Guest

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.
 
M

Mattias Sjögren

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
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top