You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2017/04/21 14:41:45 UTC

ignite git commit: IGNITE-5039 .NET: Improve error message for failed ignite.jni.dll load

Repository: ignite
Updated Branches:
  refs/heads/ignite-2.0 0c1db6777 -> 32379ee4c


IGNITE-5039 .NET: Improve error message for failed ignite.jni.dll load


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/32379ee4
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/32379ee4
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/32379ee4

Branch: refs/heads/ignite-2.0
Commit: 32379ee4c6680a58121a72c7e5b9809a713ef1c3
Parents: 0c1db67
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Fri Apr 21 17:41:37 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Fri Apr 21 17:41:37 2017 +0300

----------------------------------------------------------------------
 .../dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs         | 10 +++++++++-
 .../dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs       |  6 ++++++
 .../Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs   |  8 ++++++--
 3 files changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/32379ee4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
index 414452b..b024345 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
@@ -237,7 +237,7 @@ namespace Apache.Ignite.Core.Impl
         /// Formats the Win32 error.
         /// </summary>
         [ExcludeFromCodeCoverage]
-        private static string FormatWin32Error(int errorCode)
+        public static string FormatWin32Error(int errorCode)
         {
             if (errorCode == NativeMethods.ERROR_BAD_EXE_FORMAT)
             {
@@ -248,6 +248,14 @@ namespace Apache.Ignite.Core.Impl
                                      "Current process runs in {0} mode, and DLL is not {0}.", mode);
             }
 
+            if (errorCode == NativeMethods.ERROR_MOD_NOT_FOUND)
+            {
+                return "DLL could not be loaded (126: ERROR_MOD_NOT_FOUND). " +
+                       "This can be caused by missing dependencies. " +
+                       "Make sure that Microsoft Visual C++ 2010 Redistributable Package is installed " +
+                       "(https://www.microsoft.com/en-us/download/details.aspx?id=14632).";
+            }
+
             return string.Format("{0}: {1}", errorCode, new Win32Exception(errorCode).Message);
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/32379ee4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
index d36bf45..3403dee 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
@@ -32,6 +32,12 @@ namespace Apache.Ignite.Core.Impl
         public const int ERROR_BAD_EXE_FORMAT = 193;
 
         /// <summary>
+        /// ERROR_MOD_NOT_FOUND constant.
+        /// </summary>
+        // ReSharper disable once InconsistentNaming
+        public const int ERROR_MOD_NOT_FOUND = 126;
+
+        /// <summary>
         /// Load DLL with WinAPI.
         /// </summary>
         /// <param name="path">Path to dll.</param>

http://git-wip-us.apache.org/repos/asf/ignite/blob/32379ee4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
index 986972f..f76bbac 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
@@ -47,8 +47,12 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
             var ptr = NativeMethods.LoadLibrary(path);
 
             if (ptr == IntPtr.Zero)
-                throw new IgniteException(string.Format("Failed to load {0}: {1}", 
-                    IgniteUtils.FileIgniteJniDll, Marshal.GetLastWin32Error()));
+            {
+                var err = Marshal.GetLastWin32Error();
+
+                throw new IgniteException(string.Format("Failed to load {0} from {1}: [{2}]",
+                    IgniteUtils.FileIgniteJniDll, path, IgniteUtils.FormatWin32Error(err)));
+            }
 
             AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload;