From 2fa2972a526cd1a01df34e0dc114acd7e459fd71 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Wed, 23 Aug 2017 12:25:09 -0400 Subject: [PATCH] Clarifying TypeLoadException from class instantiation via reflection --- ICD.Common.Utils/ReflectionUtils.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ICD.Common.Utils/ReflectionUtils.cs b/ICD.Common.Utils/ReflectionUtils.cs index 0a6ecb8..66d921a 100644 --- a/ICD.Common.Utils/ReflectionUtils.cs +++ b/ICD.Common.Utils/ReflectionUtils.cs @@ -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);