Cannot start ASP.NET Core RC2 web application in IISExpress

和自甴很熟 提交于 2019-12-22 03:47:21

问题


I created a new "ASP.NET Core Web Application (.NET Core)" project in VS2015. It built without any issues, so I thought to give it a test run. However, when starting up, it choked and crashed with the following error:

Exception thrown: 'System.AggregateException' in Microsoft.AspNetCore.Server.Kestrel.dll
The program '[11608] dotnet.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.
The program '[15048] iisexpress.exe' has exited with code 0 (0x0).

I don't see anything else logged. I tried debugging it, and all I found out was that it broke during the WebHostBuilder.Run() method in Program class. It is part of the framework, so I wasn't able to get much further.

Note that the program runs fine when running via dotnet run command. Only IISExpress does not work.

How should I go about debugging this issue?

The project.json file is below. (It was generated by Visual Studio, I did not change anything.)

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0-rc2-3002702",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview1-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc2-final"
  },

  "tools": {
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    }
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "gcServer": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

Update: I created a new project for the Core RTM release, and this time it worked.


回答1:


The other issue is that you might be running an old version of the framework. Try going to the root (project.json) location of your runnable project and in a Command Prompt type:

dotnet run



回答2:


I had the same problem as you. For me the solution was to close VS2015, delete the file project.lock.json and then restart VS again. (project.lock.json will be generated automatically)

It looks like the debugger cannot attach to the application. In my case I added a throw new Exception("..."); in the first line of the function public Startup(IHostingEnvironment env) and the application just dies and doesn't break on the unhandled exception as expected.

After project.lock.json was rebuilt the debugger works fine again.




回答3:


I updated to the RTM release of dotnet core and creating a new project using the new version worked. I guess it must be a bug.




回答4:


For those bumping into this, I had the same exactly behavior and error message as described in the question.

Apparently there are some terms that can't solely be used as the project name, such as web or app. (I fixed it renaming my project to WebApp)

It was already logged as a bug and the fix will be included in the upcoming releases.

Unfortunately, after the first failed run, a project rename isn't enough to make it work, since the IIS Express config file keeps the old entry. Just edit the applicationhost.config file located at [PROJECT_ROOT]\.vs\config\ and remove the site element that is named web or app, restart VS and run it.

Hope it helps!




回答5:


I've got the same error when I run my project (not using IIS). After some investigation I found out that server url in appsettings.json (which using in Configuration) was already busy. I changed url and it worked well. Hope it helps somebody!




回答6:


I had the same error. The solution is found was that my x64 app was set to build as x86



来源:https://stackoverflow.com/questions/37329532/cannot-start-asp-net-core-rc2-web-application-in-iisexpress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!