-
Declaration referenced in a method implementation can not be a final method.
I've been testing my business objects with a little driver program called
PSSDriver. It's a Windows Form project and I've been putting my code in the
Form Load.
The code is as follows:
Option Compare Text
Option Strict On
Imports PersonShowStationMaint ' The business objects DLL
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Const MarkConn As String = "Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=Mark;Data Source=RAINSLEY"
Dim Show As New Show(MarkConn)
With Show
.GetById(90709)
.GetShowPeople()
End With
End Sub
End Class
The .GetById invocation works just fine and the Show object contains the
expected data. However, when I attempt to invoke the .GetShowPeople method, I
get the following error:
An unhandled exception of type 'System.TypeLoadException' occurred in
PSSDriver.exe
Additional information: Declaration referenced in a method implementation can
not be a final method. Type: PersonShowStationMaint.ShowPeople. Assembly:
Clear.
The declaration of the .GetById method is:
Public Function GetById(ByVal Id As Int32) As Boolean
and the declaration of the .GetShowPeople method is:
Public Sub GetShowPeople()
What am I doing wrong?
Thanks,
Bob
-
Re: Declaration referenced in a method implementation can not be a final method.
I'm making some progress. I was confused because the .GetShowPeople doesn't
have a .Clear method.
By process of elimination, I narrowed down the problem line in the method to
be:
mShowPeople.Add(ShowPerson)
mShowPeople is defined as:
Private mShowPeople As ShowPeople
ShowPeople is a typesafe collection class that does have a .Clear method. It
is defined as:
Option Compare Text
Option Strict On
Public Class ShowPeople
Inherits System.Collections.CollectionBase
Private mIdHashTable As New Hashtable()
Public Sub Add(ByVal ShowPerson As ShowPerson)
Me.List.Add(ShowPerson)
mIdHashTable.Add(CType(ShowPerson.Id, String), ShowPerson)
End Sub
Public Overrides Sub Clear()
MyBase.Clear()
mIdHashTable.Clear()
End Sub
Public ReadOnly Property IdHashTable() As Hashtable
Get
Return mIdHashTable
End Get
End Property
Default Property Item(ByVal Index As Int32) As ShowPerson
Get
Return CType(Me.List.Item(Index), ShowPerson)
End Get
Set(ByVal Value As ShowPerson)
Me.List.Item(Index) = Value
End Set
End Property
Default ReadOnly Property Item(ByVal Id As String) As ShowPerson
Get
Return CType(IdHashTable.Item(Id), ShowPerson)
End Get
End Property
Public Sub Remove(ByVal ShowPerson As ShowPerson)
Me.List.Remove(ShowPerson)
mIdHashTable.Remove(CType(ShowPerson.Id, String))
End Sub
Public Overrides Sub RemoveAt(ByVal Index As Int32)
Remove(Item(Index))
End Sub
End Class
What is the problem with how I've implemented Clear?
Thanks,
Bob
-
Re: Declaration referenced in a method implementation can not be a final method.
Bob,
I'm no expert but the docs for CollectionBase.Clear specifies that the Clear
sub is NotOverridable. Would that have anything to do with it?
--
Anthony Jones
Nuesoft Ltd
-
Re: Declaration referenced in a method implementation can not be a final method.
In article <3ce79e94@10.1.10.29>, anthony.jones@nonuesoft.spamco.uk says...
> Bob,
>
> I'm no expert but the docs for CollectionBase.Clear specifies that the Clear
> sub is NotOverridable. Would that have anything to do with it?
>
> --
> Anthony Jones
> Nuesoft Ltd
>
>
>
If that's the case, it would explain a lot. I do wonder why the compiler
didn't catch that though. It also means I need to go back and check the book
where I got the code.
Thanks, I go check that out.
Bob
-
Re: Declaration referenced in a method implementation can not be a final method.
In article <MPG.1752ae7b4e9c047d9896ea@news.devx.com>, no@spam.com says...
> In article <3ce79e94@10.1.10.29>, anthony.jones@nonuesoft.spamco.uk says...
> > Bob,
> >
> > I'm no expert but the docs for CollectionBase.Clear specifies that the Clear
> > sub is NotOverridable. Would that have anything to do with it?
> >
> > --
> > Anthony Jones
> > Nuesoft Ltd
> >
> >
> >
> If that's the case, it would explain a lot. I do wonder why the compiler
> didn't catch that though. It also means I need to go back and check the book
> where I got the code.
>
> Thanks, I go check that out.
>
> Bob
>
Anthony,
You were right. Checking out the errata for the book, it indicates that
Overrides should be changed to Shadows.
One would think that a book that purports to be for V1.0 would have gotten
this one right.
Bob
-
Re: Declaration referenced in a method implementation can not be a final method.
Bob, use Public Shadows instead of Public Overrides. This will fix your problem.
Brad
Bob <no@spam.com> wrote:
>In article <3ce79e94@10.1.10.29>, anthony.jones@nonuesoft.spamco.uk says...
>> Bob,
>>
>> I'm no expert but the docs for CollectionBase.Clear specifies that the
Clear
>> sub is NotOverridable. Would that have anything to do with it?
>>
>> --
>> Anthony Jones
>> Nuesoft Ltd
>>
>>
>>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks