diff options
author | pius.lee <pius.lee@samsung.com> | 2016-11-24 11:16:25 +0900 |
---|---|---|
committer | JongHeon Choi <j-h.choi@samsung.com> | 2016-12-14 17:08:22 +0900 |
commit | af016aa0f9cf9e442f0d122d933875c54e258a77 (patch) | |
tree | ea208b660bf7757113474854508ea0f362f639d6 /Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs | |
parent | ac952532bac864e145498a0cc724d84a67339ac0 (diff) | |
download | launcher-af016aa0f9cf9e442f0d122d933875c54e258a77.tar.gz launcher-af016aa0f9cf9e442f0d122d933875c54e258a77.tar.bz2 launcher-af016aa0f9cf9e442f0d122d933875c54e258a77.zip |
Fix Preload DLL
Use LoadFromNativeImagePath for ni dlls.
Change directory to text file for reading dll lists.
Change-Id: Icc2142a80765e4551ef6b85bdb1e1643f5c9404d
Diffstat (limited to 'Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs')
-rw-r--r-- | Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs | 52 |
1 files changed, 41 insertions, 11 deletions
diff --git a/Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs b/Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs index 26b8868..52297a1 100644 --- a/Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs +++ b/Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs @@ -105,7 +105,7 @@ namespace Tizen.Runtime.Coreclr PrintException(e); } - public static bool Initialize(string preloadDirectory) + public static bool Initialize(string preloadFile) { try { @@ -132,19 +132,49 @@ namespace Tizen.Runtime.Coreclr { CurrentAssemblyLoaderContext = new AssemblyLoader(); - if (!string.IsNullOrEmpty(preloadDirectory)) + if (!string.IsNullOrEmpty(preloadFile)) { - ALog.Debug($"Load from [{preloadDirectory}]"); - DirectoryInfo d = new DirectoryInfo(preloadDirectory); - if (Directory.Exists(d.FullName)) + ALog.Debug($"Load from [{preloadFile}]"); + FileInfo f = new FileInfo(preloadFile); + if (File.Exists(f.FullName)) { - CurrentAssemblyLoaderContext.AddSearchableDirectory(d.FullName); - string[] dlls = Directory.GetFiles(d.FullName, "*.dll"); - - foreach (string dll in dlls) + using (StreamReader sr = File.OpenText(f.FullName)) { - ALog.Debug($"preload dll : {dll}"); - CurrentAssemblyLoaderContext.LoadFromAssemblyPath(dll); + string s = String.Empty; + while ((s = sr.ReadLine()) != null) + { + ALog.Debug($"preload dll : {s}"); + try + { + Assembly asm = null; + if (s.EndsWith(".ni.dll", StringComparison.CurrentCultureIgnoreCase)) + { + asm = CurrentAssemblyLoaderContext.LoadFromNativeImagePath(s, null); + } + else + { + asm = CurrentAssemblyLoaderContext.LoadFromAssemblyPath(s); + } + + // this works strange, vm can't load types except loaded in here. + // so user code spit out not found exception. + /* + if (asm != null) + { + foreach (TypeInfo t in asm.DefinedTypes) + { + ALog.Debug("===> TYPE : " + t.FullName); + GC.KeepAlive(t.AsType()); + } + } + */ + } + catch (Exception e) + { + ALog.Debug("Exception on preload"); + PrintException(e); + } + } } } } |