Compiler Error C3392
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Compiler Error C3392.
type_arg' : invalid type argument for generic parameter 'param' of generic 'generic_type', must have a public parameterless constructor
A generic type was instantiated incorrectly. Check the type definition. For more information Generics.
The following sample, using C#, creates a component that contains a generic type, with certain constraints that are not supported when authoring generic types in Visual C++ 2005. For more information, see .Constraints on Type Parameters.
// C3392.cs
// compile with: /target:library
// a C# program
public class GR<C, V, N>
where C : class
where V : struct
where N : new() {}
The following sample generates C3392.
// C3392_b.cpp
// compile with: /clr
#using <C3392.dll>
ref class R { R(int) {} };
ref class N { N() {} };
value class V {};
ref class N2 { public: N2() {} };
ref class R2 { public: R2() {} };
int main () {
GR<R^, V, N^>^ gr1; // C3392
GR<R^, V, N2^>^ gr1a; // OK
GR<R^, N^, N^>^ gr3; // C3392
GR<R^, V, N2^>^ gr3a; // OK
GR<R^, V, R^>^ gr4; // C3392
GR<R^, V, R2^>^ gr4a; // OK
}
Show: