]> O.S.I.I.S - jp/crow.git/commitdiff
add error message and needed links for native dll resolution on windows v0.9.8-beta
authorj-p <jp_bruyere@hotmail.com>
Sun, 31 Oct 2021 17:06:50 +0000 (18:06 +0100)
committerj-p <jp_bruyere@hotmail.com>
Sun, 31 Oct 2021 17:06:50 +0000 (18:06 +0100)
Crow/src/Interface.cs

index ac8c73d469e828e284b29d5c5e836a29bc532415..66aa0e69b163745850b848d3d78b36a1c6677007 100644 (file)
@@ -76,26 +76,34 @@ namespace Crow
                                init_internal ();
                        }
                }
-
+               static void nativeHelpMessage () {
+               }
                static IntPtr resolveUnmanaged(Assembly assembly, String libraryName)
                {
-
-                       switch (libraryName)
-                       {
-                               case "cairo":
-                                       IntPtr cairoNative = NativeLibrary.Load("cairo-2", assembly, null);
-                                       if (cairoNative == IntPtr.Zero && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
-                                               Console.WriteLine ("[Error] Native dlls required by crow are not found.");
-                                               Console.WriteLine ("You can download them here:\n\thttps://onedrive.live.com/download?cid=B3181664476E9B48&resid=B3181664476E9B48%21493&authkey=AJCso6KAKMCBfAM");
-                                               Console.WriteLine ("Then extract them in one of the following directory or in your build target one: ");
-                                               foreach (string dir in System.AppContext.GetData("NATIVE_DLL_SEARCH_DIRECTORIES").ToString().Split (';'))
-                                                       Console.WriteLine ($"\t- {dir}");
-                                       }
-                                       return cairoNative;
-                               /*case "glfw3":
-                                       return NativeLibrary.Load("glfw", assembly, null);*/
-                               case "rsvg-2.40":
-                                       return NativeLibrary.Load("rsvg-2", assembly, null);
+                       try {
+                               switch (libraryName)
+                               {
+                                       case "cairo":
+                                               return NativeLibrary.Load("cairo-2", assembly, null);
+                                       /*case "glfw3":
+                                               return NativeLibrary.Load("glfw", assembly, null);*/
+                                       case "rsvg-2.40":
+                                               return NativeLibrary.Load("rsvg-2", assembly, null);
+                               }
+                       } catch {
+                               if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
+                                       Console.ForegroundColor = ConsoleColor.DarkRed;
+                                       Console.WriteLine ("Native dlls required by crow cant be found.");
+                                       Console.ResetColor();
+                                       Console.WriteLine ("You can download them here:");
+                                       Console.ForegroundColor = ConsoleColor.Blue;
+                                       Console.WriteLine ("  https://onedrive.live.com/download?cid=B3181664476E9B48&resid=B3181664476E9B48%21493&authkey=AJCso6KAKMCBfAM");
+                                       Console.ResetColor();
+                                       Console.WriteLine ("Then extract them in one of the following directories or in your project output directory.");
+                                       foreach (string dir in System.AppContext.GetData("NATIVE_DLL_SEARCH_DIRECTORIES").ToString().Split (';', StringSplitOptions.RemoveEmptyEntries))
+                                               Console.WriteLine ($" - {dir}");
+                               }
+                               Environment.Exit(0);
                        }
                        return IntPtr.Zero;
                }