NewLife/X

处理类型初始化异常
大石头 authored at 2017-07-31 20:49:00
75b47c3
Tree
1 Parent(s) e8d2088
Summary: 2 changed files with 4 additions and 1 deletions.
Modified +3 -0
Modified +1 -1
Modified +3 -0
diff --git a/NewLife.Core/Common/Utility.cs b/NewLife.Core/Common/Utility.cs
index 2c7f5e6..c2fb2dc 100644
--- a/NewLife.Core/Common/Utility.cs
+++ b/NewLife.Core/Common/Utility.cs
@@ -394,6 +394,9 @@ namespace System
             if (ex is TargetInvocationException)
                 return GetTrue((ex as TargetInvocationException).InnerException);
 
+            if (ex is TypeInitializationException)
+                return GetTrue((ex as TypeInitializationException).InnerException);
+
             return ex;
         }
     }
Modified +1 -1
diff --git a/NewLife.Core/Reflection/IReflect.cs b/NewLife.Core/Reflection/IReflect.cs
index d9e7140..c7a31d5 100644
--- a/NewLife.Core/Reflection/IReflect.cs
+++ b/NewLife.Core/Reflection/IReflect.cs
@@ -414,7 +414,7 @@ namespace NewLife.Reflection
             catch (Exception ex)
             {
                 //throw new Exception("创建对象失败 type={0} parameters={1}".F(type.FullName, parameters.Join()), ex);
-                throw new Exception("创建对象失败 type={0} parameters={1} {2}".F(type.FullName, parameters.Join(), ex.GetTrue()?.Message));
+                throw new Exception("创建对象失败 type={0} parameters={1} {2}".F(type.FullName, parameters.Join(), ex.GetTrue()?.Message), ex);
             }
         }