From 1927c7df9f6c992eab087ebef798f2de919a79c8 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Fri, 30 Jun 2017 10:51:23 -0400 Subject: [PATCH] Re-throwing inner exception from Activator.CreateInstance() --- ICD.Common.Utils/Utils/ReflectionUtils.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ICD.Common.Utils/Utils/ReflectionUtils.cs b/ICD.Common.Utils/Utils/ReflectionUtils.cs index 08656c9..4be7a4c 100644 --- a/ICD.Common.Utils/Utils/ReflectionUtils.cs +++ b/ICD.Common.Utils/Utils/ReflectionUtils.cs @@ -186,7 +186,7 @@ namespace ICD.Common.Utils public static T CreateInstance() where T : new() { - return Activator.CreateInstance(); + return (T)CreateInstance(typeof(T)); } /// @@ -198,7 +198,14 @@ namespace ICD.Common.Utils if (type == null) throw new ArgumentNullException("type"); - return Activator.CreateInstance(type); + try + { + return Activator.CreateInstance(type); + } + catch (TargetInvocationException e) + { + throw e.GetBaseException(); + } } ///