Search code examples
asp.netmacosyokestrel-http-server

Command dnx web not working on mac


I am trying to run asp.net on mac. I installed everything properly but when I run the command "dnx web" it crashes.

This is my project.json file:

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

   "dependencies": {
     "EntityFramework.Commands": "7.0.0-rc1-final",
     // Dependencies deleted for brevity.
     "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final"
   },

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

   // Markup deleted for brevity.

   "scripts": {
     "prepublish": [
       "npm install",
       "bower install",
       "gulp clean",
       "gulp min"
     ]
   }

} that is the log:

System.TypeLoadException: Could not load type 'Microsoft.Extensions.PlatformAbstractions.IAssemblyLoadContextAccessor' from assembly 'Microsoft.Extensions.PlatformAbstractions, Version=1.0.0.0, Culture=neutral,


Solution

  • I just did this on my Mac yesterday with no issues. Can you run a "dnvm list" command to ensure that the proper DNX is there?

    Did you do a "dnu restore" as well?

    Also, can you summarize the steps that you followed to get where you are now? When I first tried it, I missed a step somewhere and it didn't work for me. Then I re-read the steps and tried again, then it worked for me.

    I also realized that my port number was different from the one in the documentation so the browser couldn't find my web app the first time I had everything done right. I looked at the terminal to determine the correct port number, then got it to work in my browser.