I have created a simple ASP.NET 5 project based on the ASP.NET 5 beta 8 Visual Studio template.
I have published the project using this command
dnu publish <path to project.json> --out <path to publish folder> --configuration Release --runtime dnx-coreclr-win-x22.214.171.124-beta8 --wwwroot-out "wwwroot" --no-source
After I run the web.cmd on nano server I received this error:
.\web.cmd : System.DllNotFoundException: Unable to load DLL 'kernel32': The specified module could not be found. (Exception from HRESULT: 0x8007007E) + CategoryInfo : NotSpecified: (System.DllNotFo...LT: 0x8007007E):String) , RemoteException + FullyQualifiedErrorId : NativeCommandError at Microsoft.AspNet.Server.Kestrel.Networking.PlatformApis.WindowsApis.LoadLibrary(String dllToLoad) at Micros oft.AspNet.Server.Kestrel.Networking.Libuv.Load(String dllToLoad) at Microsoft.AspNet.Server.Kestrel.ServerFactory.Start(IFeatureCollection serverFeatures, Func`2 application) at Microsoft.AspNet.Hosting.Internal.HostingEngine.Start() at Microsoft.AspNet.Hosting.Program.Main(String args) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String args, IServiceProvider serviceProvider) at Microsoft.Dnx.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String args) at Microsoft.Dnx.ApplicationHost.Program.Main(String args) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String args, IServiceProvider serviceProvider) at Microsoft.Dnx.Host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment env, String appBase, FrameworkName targetFramework) at Microsoft.Dnx.Host.RuntimeBootstrapper.ExecuteAsync(String args, BootstrapperContext bootstrapperContext) at Microsoft.Dnx.Host.RuntimeBootstrapper.Execute(String args, BootstrapperContext bootstrapperContext)
The same command doesn't throw this error when running on Windows 10. The application works fine on Windows 10.
Nano Server does not have kernel32.dll and advapi32.dll so code that is not linked against default libs won't work. You need to either link your code against onecore.lib or install reverse forwarders.
Reverse forwarders redirect calls to kernel32.dll/advapi32.dll APIs to the counterparts available on Nano Server.
On some OneCore systems (e.g. Win10 IoT Core on Raspberry Pi 2), reverse forwarders are installed by default. This is not the case in case of the Nano Server, since the goal is to make it as small as possible. Hence the need to install reverse forwarders manually if you need them.
To relate this to Asp.Net 5 - both Http Platform Handler and Kestrel (or to be more specific libuv) are linked against default libs. Therefore, to run Asp.Net 5 on Nano, you need forwarders, unless you use WebListener (which should work fine without forwarders).
You mention that this application is working fine on Windows. How are you running it on Windows? There's a good chance you are using
dnx451 and not
dnxcore50 (CoreCLR) as your target platform.
This is a problem because you are publishing for CoreCLR. (
--runtime dnx-coreclr-win-x126.96.36.199-beta8), and there's a good chance when you are running locally, it is using the full .NET framework.
Does It Work with CoreCLR on Windows 10?
Here's what I'd do: Try to run the web app in the
Developer Command Prompt for Visual Studio 2015 using
Switch to the CoreCLR version of .NET using
dnvm use 1.0.0-beta-8 -r coreclr
If this fails, we know what is the issue. If this succeeds, there's a chance that Nano doesn't provide the native Windows APIs your code is trying to execute. If that is the case, you have to identify the code that is causing this and use something else.
How to target only CoreCLR in Visual Studio
You can remove the
dnx451 target from your
project.json so that Visual Studio is forced to use the
dnxcore50 (CoreCLR) version. Ideally we want to be running the exact same version / environment we are publishing to.
User contributions licensed under CC BY-SA 3.0