mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-15 12:45:01 +00:00
Clarifying TypeLoadException from class instantiation via reflection
This commit is contained in:
@@ -41,8 +41,15 @@ namespace ICD.Common.Utils
|
|||||||
ConstructorInfo constructor = type.GetTypeInfo().GetConstructor(types);
|
ConstructorInfo constructor = type.GetTypeInfo().GetConstructor(types);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (constructor != null)
|
try
|
||||||
return constructor.Invoke(values);
|
{
|
||||||
|
if (constructor != null)
|
||||||
|
return constructor.Invoke(values);
|
||||||
|
}
|
||||||
|
catch (TypeLoadException e)
|
||||||
|
{
|
||||||
|
throw new TypeLoadException(e.GetBaseException().Message);
|
||||||
|
}
|
||||||
|
|
||||||
string message = string.Format("Unable to find constructor for {0}", type.Name);
|
string message = string.Format("Unable to find constructor for {0}", type.Name);
|
||||||
throw new InvalidOperationException(message);
|
throw new InvalidOperationException(message);
|
||||||
|
|||||||
Reference in New Issue
Block a user