0

I have ASP.NET Core MVC 6 Web API project, which when hosted on IIS, gives the below error:

Error: Unable to load application or execute command     'Microsoft.AspNet.Server.Kestrel'. Available commands: web, ef.
System.IO.FileNotFoundException: The system cannot find the file     specified.     (Exception from HRESULT: 0x80070002)
   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.Runtime.Loader.PackageAssemblyLoader.Load(AssemblyName assemblyName)
   at Microsoft.Dnx.Host.LoaderContainer.Load(AssemblyName assemblyName)
   at Microsoft.Dnx.Host.DefaultLoadContext.LoadAssembly(AssemblyName assemblyName)
   at Microsoft.Dnx.Runtime.Loader.AssemblyLoaderCache.GetOrAdd(AssemblyName name, Func`2 factory)
   at Microsoft.Dnx.Runtime.Loader.LoadContext.LoadAssemblyImpl(AssemblyName assemblyName)
   at Microsoft.Dnx.Runtime.Loader.LoadContext.ResolveAssembly(Object sender, ResolveEventArgs args)
   at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)

Contents of project.json:

{
  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer.Design": "7.0.0-rc1-final",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final"
  },

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel",
    "ef": "EntityFramework.Commands"
  },

  "frameworks": {
    "dnx451": {
      "frameworkAssemblies": {
        "System.Data.Entity": "4.0.0.0"
      }
    },
    "dnxcore50": { }
  },

  "exclude": [
    "wwwroot",
    "node_modules"
  ],
  "publishExclude": [
    "**.user",
    "**.vspscc"
  ]
}

Please note, I have tried deleting the global.json file, and also tried running the commands dnu list, dnu restore, dnu build. Still getting the same error.

Thanks in advance.

Lex Li
  • 60,503
  • 9
  • 116
  • 147
Nands
  • 379
  • 3
  • 19
  • What does your **project.json** file look like? – Ted Nyberg Jul 19 '16 at 09:58
  • @TedNyberg : Updated the question with it. – Nands Jul 19 '16 at 10:04
  • 3
    Seems everyone is using RC1 today - you should upgrade to RTM! Also why are you using Kestrel when hosting in IIS? – DavidG Jul 19 '16 at 10:23
  • 1
    DNX as well as ASP.NET 5 (RC1) is dead. You should now drop all those bits and restart from http://dot.net – Lex Li Jul 19 '16 at 11:58
  • @DavidG: Because there are only two out-of-the-box ways to host ASP.NET Core apps: WebListener or Kestrel. WebListener doesn't work on Linux and Mac, so Kestrel is the logical choice. Even when you host ASP.NET Core on IIS you still use kestrel for the ASP.NET Core application. IIS is just setup as reverse proxy, that's why you need the ASP.NET Core Module for IIS installed – Tseng Jul 19 '16 at 11:58
  • @Tseng So it is! I really need to get a real project running in core... – DavidG Jul 19 '16 at 12:11

1 Answers1

0

Thanks everyone!! :) I switched from RC1 to RTM, and hosted the API in IIS successfully! Used the below links: docs.asp.net/en/latest/tutorials/first-web-api.html docs.asp.net/en/latest/publishing/iis.html

@DavidG : If you had 'answered' instead of 'comment', I would have marked it as the answer. Thanks anyways!

Nands
  • 379
  • 3
  • 19