Currently, when I have a class type and you need to know if the class can be created. I will call Activator.CreateInstance(type); and throw out the result.
This seems very inefficient and problematic.
Is there an alternative way to confirm that an instance type can be created for the current application?
I need to run this test as part of launching an application. To ensure that any incorrect configuration is detected before. If I leave it until an instance of the class is needed, an error can occur when no one is fixed.
Here is what I am doing now.
string className = string.Format("Package.{0}.{1}", pArg1, pArg2); Type classType = Type.GetType(className); if (classType == null) { throw new Exception(string.Format("Class not found: {0}", className)); } try {
cgTag source share