A Coder
A Coder

Reputation: 3056

Microsoft.visualbasic.collection has no type parameters

When I tried to add this property in one of class file i'm getting error.

Friend Property StatusesCollection() As New Collection(Of Status)

In this the status is a collection of properties.The error is thrown in the Status.

Error:

 Microsoft.visualbasic.collection has no type parameters an so cannot have type arguments

Upvotes: 0

Views: 1245

Answers (2)

Matt Wilko
Matt Wilko

Reputation: 27342

You have a reference to Microsoft.VisualBasic in your project which contains a Collection class. This is what the compiler thinks you are trying to use and throws your error because it is not a generic type.

However what you are trying to use is the Generic Collection object Collection(Of T) which is in the System.Collections.ObjectModel namespace.

Easiest solution is to reference the fully qualified name so that the class is no longer ambiguous. Change:

Friend Property StatusesCollection() As New Collection(Of Status)

to

Friend Property StatusesCollection() As New System.Collections.ObjectModel.Collection(Of Status)

Or use a List(Of T) instead:

Friend Property StatusesCollection() As New List(Of Status) 

See this question for a comparison: What is the difference between List (of T) and Collection(of T)?

Upvotes: 2

A Coder
A Coder

Reputation: 3056

Try adding this.

Imports System.Collections.ObjectModel

Upvotes: 0

Related Questions