mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-12 12:07:05 +00:00
Clarifying TypeLoadException from class instantiation via reflection
This commit is contained in:
parent
cd9121592a
commit
2fa2972a52
1 changed files with 9 additions and 2 deletions
|
|
@ -41,8 +41,15 @@ namespace ICD.Common.Utils
|
|||
ConstructorInfo constructor = type.GetTypeInfo().GetConstructor(types);
|
||||
#endif
|
||||
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue