Clarifying TypeLoadException from class instantiation via reflection

This commit is contained in:
Chris Cameron
2017-08-23 12:25:09 -04:00
parent cd9121592a
commit 2fa2972a52

View File

@@ -41,8 +41,15 @@ namespace ICD.Common.Utils
ConstructorInfo constructor = type.GetTypeInfo().GetConstructor(types);
#endif
if (constructor != null)
return constructor.Invoke(values);
try
{
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);
throw new InvalidOperationException(message);