Search code examples
c#asp.net-corednxdnu

Cannot run web app published with dnx


I have an app based on the preview template of ASP.NET 5 RC1 final. I publish the app by running

dnu publish --no-source --runtime active --configuration Release

The resulting package contains the runtime "dnx-clr-win-x64.1.0.0-rc1-final".

When I copy the package to another Windows machine and try to run the web command in the output\approot directory, I receive the following error:

Error: Unable to load application or execute command 'Microsoft.AspNet.Server.WebListener'. Available commands: web, webListener.
System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
   at System.Reflection.RuntimeAssembly.nLoadFile(String path, Evidence evidence)
   at System.Reflection.Assembly.LoadFile(String path)
   at Microsoft.Dnx.Runtime.Loader.LoadContext.LoadFile(String assemblyPath)
   at Microsoft.Dnx.Runtime.Loader.PackageAssemblyLoader.Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext)
   at Microsoft.Dnx.Host.LoaderContainer.Load(AssemblyName assemblyName)
   at Microsoft.Dnx.Runtime.Loader.AssemblyLoaderCache.GetOrAdd(AssemblyName name, Func`2 factory)
   at Microsoft.Dnx.Runtime.Loader.LoadContext.ResolveAssembly(Object sender, ResolveEventArgs args)
   at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)

I have tried both Kestrel and WebListener, same error message. The package works on my machine.

Is there anything else that needs to be done to make the app run on another machine?


Solution

  • The problem could be solved by extracting the ZIP file with 7-zip instead of the Windows Explorer, see also: .net local assembly load failed with CAS policy

    Thanks to @Kiran Challa for the link.