From bbb09666ddcda58564572da3c31aa085afda2ea0 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Mon, 4 May 2020 18:36:59 -0400 Subject: [PATCH] fix: Hack to catch System.Reflection constructor invocation exceptions on crestron --- ICD.Common.Utils/ReflectionUtils.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ICD.Common.Utils/ReflectionUtils.cs b/ICD.Common.Utils/ReflectionUtils.cs index 2f189ef..be25099 100644 --- a/ICD.Common.Utils/ReflectionUtils.cs +++ b/ICD.Common.Utils/ReflectionUtils.cs @@ -209,13 +209,17 @@ namespace ICD.Common.Utils ConstructorInfo constructor = GetConstructor(type, parameters); return constructor.Invoke(parameters); } - catch (TypeLoadException e) + catch (Exception e) { - throw e.GetBaseException(); - } - catch (TargetInvocationException e) - { - throw e.GetBaseException(); + // Crestron sandbox doesn't let us reference System.Reflection types... + switch (e.GetType().Name) + { + case "TypeLoadException": + case "TargetInvocationException": + throw e.GetBaseException(); + } + + throw; } }