I’m working with a hosted CLR to access a .NET-Assembly. This assembly contains generic types as:
MyGenericClass<MyClass> // C# notation
Where spAssembly is my hosted and loaded assembly, I need to get this type via string (bstrClassName).
spAssembly->GetType_2(bstrClassName, &spType); // C++-Access via hosted Assembly
So now I need to know how to format the classname-string. For regular classes i use something like
MyNamespace.MySubNamespace.MyClass // Full adressing for the query.
I guess I have to address it like this:
MyNamespace.MyGenericClass<MyNamespace.MySubNamespace.MyClass>
But this doesn’t work. Any idea? Maybe a wrong syntax?
Generics in .Net work different than C++ templates. You have to get the generic type first and then generate a concrete type from it. So you first have to get
MyGenericClassand use MakeGenericType passingMyClassas parameter.