Edit

Share via


Compiler Error C3390

'type_arg' : invalid type argument for generic parameter 'param' of generic 'generic_type', must be a reference type

A generic type was instantiated incorrectly. Check the type definition.

Remarks

For more information, see Generics.

Example

The first sample uses C# to create a component that contains a generic type. This type has certain constraints that aren't supported when authoring generic types in C++/CLI. For more information, see Constraints on Type Parameters.

// C3390.cs
// Compile by using: csc /target:library C3390.cs
// a C# program
public class GR<C, V, N>
where C : class
where V : struct
where N : new() {}

When the C3390.dll component is available, the following sample generates C3390.

// C3390_b.cpp
// Compile by using: cl /clr C3390_b.cpp
#using <C3390.dll>
ref class R { R(int) {} };
value class V {};
ref struct N { N() {} };

int main () {
   GR<V, V, N^>^ gr2;   // C3390 first type must be a ref type
   GR<R^, V, N^>^ gr2b; // OK - do this instead
}