ASP.NET Core 或 ASP.NET Core MVC 解决方案无法运行,IIS Express 抛出 HTTP 错误 500.30 - ASP.NET Core 应用程序无法启动 [英] ASP.NET Core or ASP.NET Core MVC solution fails to run, IIS Express throws HTTP Error 500.30 - ASP.NET Core app failed to start

查看:60
本文介绍了ASP.NET Core 或 ASP.NET Core MVC 解决方案无法运行,IIS Express 抛出 HTTP 错误 500.30 - ASP.NET Core 应用程序无法启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使是最简单的Hello world",我也遇到过这个错误.Visual Studio 中的 ASP.NET Core Web 应用程序.(Win 10 Pro、IIS Express、VS 2019 CE.)重现步骤:

  1. 在 Visual Studio 2019 中创建新的 ASP.NET Core 或 ASP.NET Core MVC 解决方案.选择选项以生成基本hello world"的脚手架代码应用程序.无论您的目标是 .NET Core 2.1、.NET Core 3.1 还是 .NET 5.0,在我尝试的场景中结果都是一样的.

  2. 项目和解决方案加载,源代码可见且看起来正确.按F5运行它.应用编译但不运行.

预期行为:hello world"应用加载.

实际行为:在网络浏览器中显示此错误消息:

<块引用>

HTTP 错误 500.30 - ASP.NET Core 应用程序无法启动"(还有一些故障排除步骤,然后)有关更多信息,请访问:https://go.microsoft.com/fwlink/?LinkID=2028265".

  1. 继续并点击该链接,然后使用这些资源仔细检查您是否拥有所有需要的包并且您的 IIS 配置正确.我的机器在我的机器上看起来很好,但我仍然收到这个错误.我什至尝试重新安装 VS、托管包、IIS 等,但无济于事.

<块引用>

注意:此问题与500.32 ANCM Failed To加载 DLL"或500.36 ANCM 进程外处理程序加载失败"错误,但我在故障排除过程中也遇到了这些错误,所以我在这里提及它们,以防对其他人有帮助.

<块引用>

另请注意:您不一定有损坏的 ASP.NET Core模块为 这个文档会让你相信.

  1. 检查事件日志,您会发现其中存在一些错误,但在这种情况下,这些错误对诊断问题没有特别帮助.就我而言,它只是说

<块引用>

"应用程序 '/LM/W3SVC/2/ROOT' 具有物理根目录 'H:Repo(R;)sandboxAspNetCoreWebApp001AspNetCoreWebApp001'加载失败核心资源异常消息:CLR 工作线程提前退出"

<块引用>

"应用程序已从 Program.Main 退出,退出代码 ='-2147450743'.请检查 stderr 日志以获取更多信息."

他们将 IIS Express AspNetCore 模块显示为源.供应商文档在这种情况下并没有太大帮助.

  1. 再次检查以确保 IIS 配置正确,并且安装了正确的包,包括 .NET Core 托管包.如果不这样做,或者如果您像我在故障排除期间一样尝试不同的配置,那么您可能会看到上面提到的 ANCM 错误.如果您遇到这些错误,请查看 两个 链接 可以提供帮助.我阅读了这些链接并多次仔细检查了我的机器.就我而言,这一切都是正确和完整的,但我仍然有错误.

  2. 再和电脑打几下,叫它一些坏名字,第三次重新安装Visual Studio,第八次验证IIS设置,向你的朋友寻求帮助,再次检查SO和Google.简单的 hello world 应用程序仍然无法运行,同样的错误.它在另一台机器上运行,所以代码本身没有任何问题.

解决方案

这是最终在我的机器上修复它的解决方案:我将解决方案移到了不同​​的文件夹. HUH??? 我问,这怎么可能解决这个问题.经过一番折腾,我终于找到了根本原因:路径中有一个分号.是的.就我而言,我一直将解决方案存储在名为H:Repo (R;)"的目录中.事实证明,即使 Windows 操作系统允许使用 ; 字符,.NET CLR 根本不喜欢它,也不知道如何处理它.因此它会生成无用的错误消息.

试试看.重命名这应该可以正常工作"的文件夹解决方案删除分号,关闭并重新打开VS中的解决方案,按F5并观察它运行.或者转到工作解决方案并将文件夹重命名为包含分号,然后观察它是否会破坏 CLR.​​

我很好奇文件夹名称中的任何其他特殊字符是否会导致问题,所以我检查了所有这些字符(在文件夹上,而不是文件名上,但我希望文件名也有类似的结果).这是我的详尽测试:

Windows 不允许在文件夹名称中使用这些:

/:*?"<>|

当路径包含以下任何特殊字符时,解决方案将加载并运行:

`~-_+=',.()[]{}!@#$%&

但是,在 Windows 允许的路径中包含这些字符中的任何一个都会导致 CLR 或 Visual Studio 中的问题:

; 导致HTTP 错误 500.30 - ASP.NET Core 应用程序无法启动"

^ VS 加载失败解决方案 &显示错误信息如下:

<块引用>

"在命令行中指定了以下文件:<.sln 文件>找不到这些文件,也不会加载这些文件."而是加载了一个完全空的 VS 实例.

我还尝试创建一个新的你好世界";VS 中的控制台应用程序位于名称中包含分号的文件夹下,你猜怎么着?这也无法运行.虽然在这种情况下,显然 IIS 没有 HTTP 错误.相反,它说

<块引用>

未能创建 CoreCLR,HRESULT:0x80070057"

并抛出进程退出代码.再一次,这是路径中有分号的结果,因为从路径中删除该分号并在 VS 中重新加载解决方案可以使其正确运行.所以分号问题似乎源于CLR,因此与IIS无关.

以下是一些有关根本原因的相关帖子,对于在 IIS Express 上运行的 Web 应用程序而言,这些原因并不明显:

未能创建 CoreCLR,HRESULT:0x80070057

https://github.com/dotnet/sdk/issues/13954

因此,感谢那些对 RCA 非常有帮助的帖子的作者.

有人会认为操作系统允许的特殊字符也可以用于 Visual Studio 代码的路径中.那好吧.吸取的教训.

I've been having this error happen on even the simplest "Hello world" ASP.NET Core web app in Visual Studio. (Win 10 Pro, IIS Express, VS 2019 CE.) Steps to reproduce:

  1. Create a new ASP.NET Core or ASP.NET Core MVC solution in Visual Studio 2019. Select the options to generate the scaffolding code for the basic "hello world" app. It doesn't matter whether you target .NET Core 2.1, .NET Core 3.1, or .NET 5.0, the result is the same in the scenarios I attempted.

  2. The project and solution loads and the source code is visible and looks correct. Press F5 to run it. App compiles but does not run.

Expected behavior: the "hello world" app loads.

Actual behavior: shows this error message in the web browser:

"HTTP Error 500.30 - ASP.NET Core app failed to start" (and some troubleshooting steps, then) "For more information visit: https://go.microsoft.com/fwlink/?LinkID=2028265".

  1. Go ahead and follow that link, then use those resources to double-check that you have all the needed packages and your IIS is configured properly. Mine was all looking good on my machine, but still I was getting this error. I even tried reinstalling VS, the hosting bundle, IIS, etc. but to no avail.

NOTE: This issue is a little different than the "500.32 ANCM Failed To Load DLL" or the "500.36 ANCM Out-Of-Process Handler Load Failure" errors, but I also encountered those during my troubleshooting, so I'm mentioning them here in case it helps someone else.

NOTE ALSO: you do not necessarily have a corrupted ASP.NET Core Module as this documentation would have you believe.

  1. Check the event logs, you'll find some errors in there, but those are not particularly helpful in diagnosing the issue in this case. In my case, it just says

"Application '/LM/W3SVC/2/ROOT' with physical root 'H:Repo (R;)sandboxAspNetCoreWebApp001AspNetCoreWebApp001' failed to load coreclr. Exception message: CLR worker thread exited prematurely"

and

"Application has exited from Program.Main with exit code = '-2147450743'. Please check the stderr logs for more information."

They show IIS Express AspNetCore Module as the source. Vendor docs were not terribly helpful on this scenario.

  1. Double check to be sure you've got your IIS configration correct, and that you have the right packages installed, including the .NET Core Hosting Bundle. If you don't, or if you're trying different configurations like I was during troubleshooting, then you might see the ANCM errors mentioned above. If you get those errors, here are two links that can help. I read those links and checked my machine carefully, multiple times. In my case, this was all correct and complete, and I still had the error.

  2. Fight with the computer some more, call it some bad names, reinstall Visual Studio for the 3rd time, verify IIS settings for the 8th time, ask your friends for help, check SO and Google yet again. The simple hello world app still won't run, same error. It runs on another machine, so there's nothing wrong with the code itself.

解决方案

This was the solution that eventually fixed it on my machine: I moved the solution to a different folder. HUH??? How could that possibly fix this issue, I asked. After more head-banging, I eventually arrived at the root cause: a semicolon in the path. Yup. In my case, I had been storing the solution in a directory called "H:Repo (R;)". It turns out, even though the ; character is allowed by the Windows OS, the .NET CLR does not like it at all and doesn't know what to do with it. So it generates the unhelpful error message.

Try it out. Rename the folder of your "this should be working" solution to remove the semicolons, close and reopen the solution in VS, press F5 and watch it run. Or go to a working solution and rename the folder to contain a semicolon and watch it break the CLR.

I was curious whether any other special characters in a folder name would cause an issue, so I checked them all (on folders, not on filenames, but I'd expect a similar result for filenames too). Here's my exhaustive test:

Windows disallows these in folder names:

/:*?"<>|

The solution will load and run when the path contains any of these special characters:

`~-_+=',.()[]{}!@#$%&

However, having any of these characters in the path, while being allowed by Windows, will cause issues in the CLR or in Visual Studio:

; Causes "HTTP Error 500.30 - ASP.NET Core app failed to start"

^ VS fails to load the solution & shows error message as follows:

"The following files were specified on the command line: <the .sln file> These files could not be found and will not be loaded." A totally empty instance of VS loads instead.

I also tried creating a new "hello world" console app in VS under a folder containing a semicolon in the name, and guess what? That also fails to run. Though in that case, obviously there is no HTTP error from IIS. Instead, it says

"Failed to create CoreCLR, HRESULT: 0x80070057"

and throws a process exit code. Once again, it's the result of having a semicolon in the path, because removing that semicolon from the path and reloading the solution in VS allows it to run correctly. So the semicolon issue seems to be originating from the CLR and therefore is unrelated to IIS.

Here are some related posts regarding the root cause, which is not readily apparent for web apps running on IIS Express:

Failed to create CoreCLR, HRESULT: 0x80070057

https://github.com/dotnet/sdk/issues/13954

So, kudos to those authors for those posts which were very helpful in the RCA.

One would think that the special characters allowed by the OS would also be fair game to use in the path to your Visual Studio code. Oh well. Lesson learned.

这篇关于ASP.NET Core 或 ASP.NET Core MVC 解决方案无法运行,IIS Express 抛出 HTTP 错误 500.30 - ASP.NET Core 应用程序无法启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆