|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
The generic type 'System.Collections.ObjectModel.Collection`1' was used with the wrong number of genI am seeing the same problem. The code seems to run ok but while I am stepping through it while debugging VS shows the value of count in my watch window as this error: {"The generic type 'System.Collections.ObjectModel.Collection`1' was used with the wrong number of generic arguments in assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.":"System.Collections.ObjectModel.Collection`1"} Integer Like I said the code seems to be running ok but I am concerned that there is an underlying problem. Basically I have an abstract base class that derives from System.Collections.ObjectModel.Collection(Of T). I then have classes that derive from my base class. Any thoughts? Here is some code (in VB.NET) to go along with the problem.
'setup the following types: Public Interface IStyle End Interface Public Interface IColor Inherits IStyle End Interface Public Class Red Implements IColor End Class Public Class Blue Implements IColor End Class Public Class Green Implements IColor End Class Public MustInherit Class StyleCollection(Of T As IStyle) Inherits System.Collections.ObjectModel.Collection(Of T) Public ReadOnly Property Test() As Integer Get Dim c As Integer c = Me.Count c = Me.Items.Count Return c End Get End Property End Class Public Class ColorCollection Inherits StyleCollection(Of IColor) End Class 'Instantiate a ColorCollection and add some colors to it Dim colors As New ColorCollection Dim r As New Red Dim b As New Blue Dim g As New Green colors.Add(r) colors.Add(b) colors.Add(g) Set a break point in the Test() property and step through the code. Take a look at Me.Count & Me.Items in the watch window. Instead of the value, you should see the error: {"The generic type 'System.Collections.ObjectModel.Collection`1' was used with the wrong number of generic arguments in assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.":"System.Collections.ObjectModel.Collection`1"} System.Collections.Generic.IList(Of T) Keep in mind the value is actually there and the code works ok. |
|||||||||||||||||||||||