diff options
author | pius.lee <pius.lee@samsung.com> | 2016-11-15 15:49:52 +0900 |
---|---|---|
committer | pius.lee <pius.lee@samsung.com> | 2016-11-15 15:52:17 +0900 |
commit | d1996eaf33451d4c9ceb207247c8c2f33107ab09 (patch) | |
tree | 8429f66944059eb4adb0b9efd6762233e6be95ed | |
parent | 8cd6fb2c60ac74259fdce9615836949e9d0ef7fc (diff) | |
download | launcher-d1996eaf33451d4c9ceb207247c8c2f33107ab09.tar.gz launcher-d1996eaf33451d4c9ceb207247c8c2f33107ab09.tar.bz2 launcher-d1996eaf33451d4c9ceb207247c8c2f33107ab09.zip |
Add Unhandled Exception handler for Dlog output
Add temporarily implmentation until become Appdomain on API
Change-Id: I6c622d701d94cf3cc29262e066a490f102cfd46b
-rw-r--r-- | Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs b/Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs index 39ff2fa..acbb06e 100644 --- a/Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs +++ b/Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs @@ -78,10 +78,33 @@ namespace Tizen.Runtime.Coreclr } } + public static void UnhandledExceptionHandler(object sender, object args) + { + TypeInfo unhandledExceptionEventArgsType = + Type.GetType("UnhandledExceptionEventArgs").GetTypeInfo(); + + PropertyInfo exception = unhandledExceptionEventArgsType.GetProperty("ExceptionObject"); + Exception e = (Exception)exception.GetValue(args); + + PrintException(e); + } + public static bool Initialize(string preloadDirectory) { try { + // Set UnhandledException handler with reflection + // we must replace this to no reflection method after AppDomain is comming in used net standard + TypeInfo appdomainType = Type.GetType("System.AppDomain").GetTypeInfo(); + PropertyInfo currentDomain = appdomainType.GetProperty("CurrentDomain", + BindingFlags.Public | BindingFlags.Static); + EventInfo unhandledException = appdomainType.GetDeclaredEvent("UnhandledException"); + object appdomain = currentDomain.GetValue(null, null); + MethodInfo handlerInfo = typeof(AssemblyManager).GetTypeInfo().GetDeclaredMethod("UnhandledExceptionHandler"); + Delegate handler = handlerInfo.CreateDelegate(unhandledException.EventHandlerType); + var addMethod = unhandledException.GetAddMethod(true); + addMethod.Invoke(appdomain, new[] {handler}); + CurrentAssemblyLoaderContext = new AssemblyLoader(); if (!string.IsNullOrEmpty(preloadDirectory)) |