mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-13 12:37:13 +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);
|
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);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue