Re-throwing inner exception from Activator.CreateInstance()

This commit is contained in:
Chris Cameron
2017-06-30 10:51:23 -04:00
parent a802528fed
commit 1927c7df9f

View File

@@ -186,7 +186,7 @@ namespace ICD.Common.Utils
public static T CreateInstance<T>() public static T CreateInstance<T>()
where T : new() where T : new()
{ {
return Activator.CreateInstance<T>(); return (T)CreateInstance(typeof(T));
} }
/// <summary> /// <summary>
@@ -198,7 +198,14 @@ namespace ICD.Common.Utils
if (type == null) if (type == null)
throw new ArgumentNullException("type"); throw new ArgumentNullException("type");
return Activator.CreateInstance(type); try
{
return Activator.CreateInstance(type);
}
catch (TargetInvocationException e)
{
throw e.GetBaseException();
}
} }
/// <summary> /// <summary>