From c5aacbcd52fb781797e18d5f853abec64f4c577d Mon Sep 17 00:00:00 2001 From: Michael Oborne Date: Sun, 18 Feb 2018 07:55:46 +0800 Subject: [PATCH] SkiaSharp: load correct arch --- MainV2.cs | 33 +++++++++++++++++++++++++++++++++ MissionPlanner.csproj | 10 +++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/MainV2.cs b/MainV2.cs index 0660e0967b..873531e0ee 100644 --- a/MainV2.cs +++ b/MainV2.cs @@ -58,6 +58,25 @@ internal static extern IntPtr RegisterDeviceNotification static public int SW_SHOWNORMAL = 1; static public int SW_HIDE = 0; + + [DllImport("kernel32.dll", SetLastError = true)] + public static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hReservedNull, LoadLibraryFlags dwFlags); + + [System.Flags] + public enum LoadLibraryFlags : uint + { + DONT_RESOLVE_DLL_REFERENCES = 0x00000001, + LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010, + LOAD_LIBRARY_AS_DATAFILE = 0x00000002, + LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040, + LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020, + LOAD_LIBRARY_SEARCH_APPLICATION_DIR = 0x00000200, + LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x00001000, + LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR = 0x00000100, + LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800, + LOAD_LIBRARY_SEARCH_USER_DIRS = 0x00000400, + LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008 + } } public static menuicons displayicons = new burntkermitmenuicons(); @@ -537,6 +556,18 @@ public MainV2() SetStyle(ControlStyles.OptimizedDoubleBuffer, true); + try + { + if (Environment.Is64BitProcess) + { + var skia = NativeMethods.LoadLibraryEx("x64/libSkiaSharp.dll", IntPtr.Zero, 0); + } + else + { + var skia = NativeMethods.LoadLibraryEx("x86/libSkiaSharp.dll", IntPtr.Zero, 0); + } + } catch { } + // set this before we reset it Settings.Instance["NUM_tracklength"] = "200"; @@ -981,6 +1012,8 @@ public MainV2() MenuDonate.Image = Program.Logo; } + + Application.DoEvents(); Comports.Add(comPort); diff --git a/MissionPlanner.csproj b/MissionPlanner.csproj index 889676fedd..2c656a0fca 100644 --- a/MissionPlanner.csproj +++ b/MissionPlanner.csproj @@ -19,7 +19,7 @@ false false true - + false dev @@ -230,6 +230,7 @@ + @@ -1963,4 +1964,11 @@ + + + Never + + + + \ No newline at end of file