From 1e25a3a683bfebcad0e4c3108a96157e30fdd352 Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Mon, 3 Mar 2014 19:17:17 +0100 Subject: [PATCH] MKL: catch DllNotFoundException if provider is not available #198 --- .../LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs index 8cc065a4..98064d4e 100644 --- a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs +++ b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs @@ -126,9 +126,13 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl _nativeRevision = SafeNativeMethods.query_capability(64); linearAlgebra = SafeNativeMethods.query_capability(128); } + catch (DllNotFoundException e) + { + throw new NotSupportedException("MKL Native Provider not found.", e); + } catch (BadImageFormatException e) { - throw new NotSupportedException("MKL Native Provider failed to load. Please verify that the platform matches (x64 vs x32, Windows vs Linux).", e); + throw new NotSupportedException("MKL Native Provider found but failed to load. Please verify that the platform matches (x64 vs x32, Windows vs Linux).", e); } catch (EntryPointNotFoundException e) { @@ -137,12 +141,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl // TODO: drop return statement and instead fail with the exception below return; - throw new NotSupportedException("MKL Native Provider does not support capability querying and is therefore not compatible. Try to upgrade to a newer version (1).", e); + throw new NotSupportedException("MKL Native Provider found but does not support capability querying and is therefore not compatible. Try to upgrade to a newer version.", e); } if (a != 0 || b != -1 || linearAlgebra <=0 || _nativeRevision < 4) { - throw new NotSupportedException("MKL Native Provider too old or not compatible (2)."); + throw new NotSupportedException("MKL Native Provider found but too old or not compatible."); } if (SafeNativeMethods.query_capability(65) > 0)