This is not such an obscure problem as it is just not straight forward to solve. Simply put you cannot instantiate a new instance of a generic object without explicitly saying that the method/class you are trying to do this inside of must allow for it.

Let’s Review That Error One More Time
New cannot be used on a type parameter that does not have a new constraint.

Code that will Cause this Error

So What This Really Means Is…
The new keyword cannot be used to instantiate an object of type T if the method/class that it is being used in side of did not explicitly define it as a constraint of the method/class.

Code That Will Compile Happily


Resources
Constraints on Type Parameters VB.Net

Constraints on Type Parameters C#

https://www.google.com/search?q=constraints+on+type+parameters+vb.net
https://www.google.com/search?q=constraints+on+type+parameters+C#

2 thoughts on “New cannot be used on a type parameter that does not have a new constraint

    1. I am not 100% sure about this, but try including your type into the set and separating the types by commas.

      Private Sub GenericMethod(Of T As {MyType, New})(parameter1 As Integer)

Leave a Reply

Your email address will not be published. Required fields are marked *