From e421b3f01c2a1875c36204abda3f8f029a1b0fa0 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Fri, 26 Dec 2014 14:37:37 -0800 Subject: [PATCH] Throw better error when libuv can't be loaded - Throw more specific exception for *nix machines --- .../Networking/Libuv.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Microsoft.AspNet.Server.Kestrel/Networking/Libuv.cs b/src/Microsoft.AspNet.Server.Kestrel/Networking/Libuv.cs index 741c3b48f8..977fb18260 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Networking/Libuv.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Networking/Libuv.cs @@ -31,6 +31,20 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking PlatformApis.Apply(this); var module = LoadLibrary(dllToLoad); + + if (module == IntPtr.Zero) + { + var message = "Unable to load libuv."; + if (!IsWindows && !IsDarwin) + { + // *nix box, so libuv needs to be installed + // TODO: fwlink? + message += " Make sure libuv is installed and available as libuv.so.1"; + } + + throw new InvalidOperationException(message); + } + foreach (var field in GetType().GetTypeInfo().DeclaredFields) { var procAddress = GetProcAddress(module, field.Name.TrimStart('_'));