I would like to get type from generic type fullname like that :
var myType = Type.GetType(\"MyProject.MyGenericType`1[[MyProject.MySimpleType, MyProject, Ver
If you don't specify the assembly qualified name, Type.GetType
works only for mscorlib
types. In your example you has defined the AQN only for the embedded type argument.
// this returns null:
var type = Type.GetType("MyProject.MyGenericType`1[[MyProject.MySimpleType, MyProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]");
// but this works:
var type = Type.GetType("MyProject.MyGenericType`1[[MyProject.MySimpleType, MyProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], MyProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
Your original type string will work though, if you use Assembly.GetType
instead of Type.GetType
:
var myAsm = typeof(MyGenericType<>).Assembly;
var type = myAsm.GetType("MyProject.MyGenericType`1[[MyProject.MySimpleType, MyProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]");