I´m using Type.GetType()
to create a instance.
This works:
var type = Type.GetType("Test.ClassServices.HowService, Test");
But, this doesn´t work. It returns null
:
var name = "How";
var type = Type.GetType("Test.ClassServices."+name+"Service, Test");
No-repro. Run this sample:
var hardCodedWorking = Type.GetType("System.String");
var stringName = "String";
var concatenatedWorking = Type.GetType("System." + stringName);
var badStringName = "string";
var concatenatedNull = Type.GetType("System." + badStringName);
From Type.GetType() on MSDN:
Gets the Type with the specified name, performing a case-sensitive search.
Based on that and my example above, I believe it's most likely that the value of name
isn't matching the name of the class perfectly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With