我是 .NET Core 的初学者。我正在学习 Lynda 的“学习 ASP.NET Core MVC 基础知识”类(class)。当我尝试学习第 1 章视频 5 的示例代码时,出现此错误:
HTTP Error 502.5 - Process Failure
Common causes of this issue:
The application process failed to start
The application process started but then stopped
The application process started but failed to listen on the configured port
Troubleshooting steps:
Check the system event log for error messages
Enable logging the application process' stdout messages
Attach a debugger to the application process and inspect
For more information visit: https://go.microsoft.com/fwlink/?LinkID=808681
经过Stack Overflow上的几个问题后,我发现这是由于练习文件中包含较旧的.NET Core版本(1.0)引起的。但是我电脑里的 Visual Studio 版本是 2.1.4。练习中的文件夹“wwwroot”也可能导致问题。
似乎我能解决这个问题的唯一方法是降级到 1.0 版。但是我该怎么做呢?我是否必须卸载 Visual Studio Code 并使用 .NET Core V 1.0 安装它?
最佳答案
“降级”不是 Visual Studio 支持的功能。
选项 1
查找使用 .NET Core 2.0 的教程。 Microsoft 有非常好的教程和文档,具体取决于您想要涵盖的内容。
.NET Core 1.0 基本上是微软称为 1.0 的 beta。由于与 .NET Core 2.0 相比功能(和实用性)有限,此时学习 .NET Core 1.0 将一无所获。
.NET Core 2.1 也即将发布。
选项 2
在 Visual Studio 2017 中创建一个以 .NET Core 1.0 为目标的新项目,并将所有 .NET Core 1.0 代码放在那里。
- 选择 ASP.NET Core Web 应用程序并为项目命名。点击确定。
- 在下一个屏幕上,从下拉列表中将项目更改为以 .NET Core 1.0 为目标。从教程中选择任何其他选项。点击确定。
选项 3
将您的 .NET Core 2.0 项目重新定位到 .NET Core 1.0。
- 在解决方案资源管理器中,右键单击项目并选择
Edit <projectName>.csproj
.
- 更改
TargetFramework
来自netcoreapp2.0
的元素至netcoreapp1.0
.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework>
</PropertyGroup>
...
</Project>
- 修复进行此更改可能会产生的任何编译问题。每个项目都会有不同的问题,具体取决于项目引用的内容。没有这方面的指南,您需要进行研究以找出问题所在并自行解决。 Google 是您的 friend 。
NOTE: None of this will likely fix the underlying cause to your error message, which is a completely different Stack Overflow question than what you are asking here.
关于c# - 如何降级到.NET Core 1.0?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49349614/