[NUI.Gadget] Change assembly load mothod (#5914)
authorhjhun <36876573+hjhun@users.noreply.github.com>
Fri, 26 Jan 2024 00:12:44 +0000 (09:12 +0900)
committerGitHub <noreply@github.com>
Fri, 26 Jan 2024 00:12:44 +0000 (09:12 +0900)
- Use LoadFromNativeImagePath() instead of LoadFromStream()

Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetAssembly.cs

index 9cfb199..b5dd7e0 100644 (file)
@@ -19,6 +19,8 @@ using System.IO;
 using System.Reflection;
 using System.Runtime.Loader;
 
+using SystemIO = System.IO;
+
 namespace Tizen.NUI
 {
     internal class NUIGadgetAssemblyLoadContext : AssemblyLoadContext
@@ -54,10 +56,11 @@ namespace Tizen.NUI
                 Log.Warn("Load(): " + _assemblyPath + " ++");
                 NUIGadgetAssemblyLoadContext context = new NUIGadgetAssemblyLoadContext();
                 _assemblyRef = new WeakReference(context);
-                using (MemoryStream memoryStream = new MemoryStream(File.ReadAllBytes(_assemblyPath)))
-                {
-                    _assembly = context.LoadFromStream(memoryStream);
-                }
+                string directoryPath = SystemIO.Path.GetDirectoryName(_assemblyPath);
+                string fileName = SystemIO.Path.GetFileNameWithoutExtension(_assemblyPath);
+                string nativeImagePath = directoryPath + "/" + fileName + ".ni.dll";
+                Log.Debug("NativeImagePath=" + nativeImagePath + ", AssemblyPath=" + _assemblyPath);
+                _assembly = context.LoadFromNativeImagePath(nativeImagePath, _assemblyPath);
                 Log.Warn("Load(): " + _assemblyPath + " --");
             }
         }