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 2016/06/16 11:15:04 UTC
ignite git commit: IGNITE-3317 .NET: Improve error message when
jvm.dll could not be loaded
Repository: ignite
Updated Branches:
refs/heads/master 4ed02fd02 -> 9d46a73f2
IGNITE-3317 .NET: Improve error message when jvm.dll could not be loaded
This closes #806
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9d46a73f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9d46a73f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9d46a73f
Branch: refs/heads/master
Commit: 9d46a73f20dfa4c505c7be0f6b4199e3cf350c0e
Parents: 4ed02fd
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Thu Jun 16 14:14:43 2016 +0300
Committer: Pavel Tupitsyn <pt...@gridgain.com>
Committed: Thu Jun 16 14:14:43 2016 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core/Impl/IgniteUtils.cs | 22 ++++++++++++++++++--
.../Apache.Ignite.Core/Impl/NativeMethods.cs | 6 ++++++
2 files changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d46a73f/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 5c19802..e992e81 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Impl
{
using System;
using System.Collections.Generic;
+ using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
@@ -191,8 +192,8 @@ namespace Apache.Ignite.Core.Impl
if (errCode == 0)
return;
- messages.Add(string.Format(CultureInfo.InvariantCulture, "[option={0}, path={1}, errorCode={2}]",
- dllPath.Key, dllPath.Value, errCode));
+ messages.Add(string.Format(CultureInfo.InvariantCulture, "[option={0}, path={1}, error={2}]",
+ dllPath.Key, dllPath.Value, FormatWin32Error(errCode)));
if (dllPath.Value == configJvmDllPath)
break; // if configJvmDllPath is specified and is invalid - do not try other options
@@ -214,6 +215,23 @@ namespace Apache.Ignite.Core.Impl
}
/// <summary>
+ /// Formats the Win32 error.
+ /// </summary>
+ private static string FormatWin32Error(int errorCode)
+ {
+ if (errorCode == NativeMethods.ERROR_BAD_EXE_FORMAT)
+ {
+ var mode = Environment.Is64BitProcess ? "x64" : "x86";
+
+ return string.Format("DLL could not be loaded (193: ERROR_BAD_EXE_FORMAT). " +
+ "This is often caused by x64/x86 mismatch. " +
+ "Current process runs in {0} mode, and DLL is not {0}.", mode);
+ }
+
+ return string.Format("{0}: {1}", errorCode, new Win32Exception(errorCode).Message);
+ }
+
+ /// <summary>
/// Try loading DLLs first using file path, then using it's simple name.
/// </summary>
/// <param name="filePath"></param>
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d46a73f/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 eb3ba97..d36bf45 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
@@ -26,6 +26,12 @@ namespace Apache.Ignite.Core.Impl
internal static class NativeMethods
{
/// <summary>
+ /// ERROR_BAD_EXE_FORMAT constant.
+ /// </summary>
+ // ReSharper disable once InconsistentNaming
+ public const int ERROR_BAD_EXE_FORMAT = 193;
+
+ /// <summary>
/// Load DLL with WinAPI.
/// </summary>
/// <param name="path">Path to dll.</param>