mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-07 00:35:12 +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);
|
||||
#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);
|
||||
|
||||
Reference in New Issue
Block a user