一个.NET API服务在部署到Ubuntu服务器时显示(code=exited, status=203/EXEC)。

huangapple go评论97阅读模式
英文:

A .NET API service shows (code=exited, status=203/EXEC) when Deploying to an Ubuntu Server

问题

我想部署一个使用.NET 5创建的WebAPI到Hetzner服务器,我已经根据这个网站的步骤部署了它部署.NET。一切都运行正常,直到我运行服务并检查其状态时,它显示了一个关于我的 WebApi.dll 的错误。

root@ubuntu:/# systemctl status  MinAPIservice.service
● MinAPIservice.service - ASP .NET Web Application
     Loaded: loaded (/etc/systemd/system/MinAPIservice.service; enabled; preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Tue 2023-06-13 09:58:40 UTC; 1s ago
    Process: 52726 ExecStart=/usr/bin/dotnet /var/www/MinAPI/MinWebApi.dll (code=exited, status=203/EXEC)
   Main PID: 52726 (code=exited, status=203/EXEC)
        CPU: 775us

为了找到问题,我运行了以下命令 /etc/systemd/system# /usr/bin/dotnet /var/www/MinAPI/WebApi.dll 在系统目录中,并显示了以下错误:

root@ubuntu:/etc/systemd/system# /usr/bin/dotnet /var/www/MinAPI/WebApi.dll
You must install or update .NET to run this application.

App: /var/www/MinAPI/WebApi.dll
Architecture: x64
Framework: 'Microsoft.AspNetCore.App', version '5.0.0' (x64)
.NET location: /usr/lib/dotnet/

The following frameworks were found:
   6.0.16 at [/root/.dotnet/shared/Microsoft.AspNetCore.App]
  7.0.5 at [/root/.dotnet/shared/Microsoft.AspNetCore.App]

Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failed

To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=5.0.0&arch=x64&rid=ubuntu.23.04-x64

现在我的服务器显示503 - 服务不可用...

我尝试安装.NET 5.0,但不再支持Ubuntu 23.04,还尝试安装.NET 6.0,问题仍然存在,我想找到解决这个错误的方法来使用Swagger运行我的API。

英文:

I want to deploy a WebAPI create with .NET 5 to a Hetzner server, I have deployed it based on the steps of this website Deploy .NET.
Everything works fine, until I run the Service and check its status, it shows an error with my WebApi.dll

root@ubuntu:/# systemctl status  MinAPIservice.service
● MinAPIservice.service - ASP .NET Web Application
     Loaded: loaded (/etc/systemd/system/MinAPIservice.service; enabled; preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Tue 2023-06-13 09:58:40 UTC; 1s ago
    Process: 52726 ExecStart=/usr/bin/dotnet /var/www/MinAPI/MinWebApi.dll (code=exited, status=203/EXEC)
   Main PID: 52726 (code=exited, status=203/EXEC)
        CPU: 775us

And to find the problem I have run the following command
/etc/systemd/system# /usr/bin/dotnet /var/www/MinAPI/WebApi.dll in the system directory, and shows the following error:

root@ubuntu:/etc/systemd/system# /usr/bin/dotnet /var/www/MinAPI/WebApi.dll
You must install or update .NET to run this application.

App: /var/www/MinAPI/WebApi.dll
Architecture: x64
Framework: 'Microsoft.AspNetCore.App', version '5.0.0' (x64)
.NET location: /usr/lib/dotnet/

The following frameworks were found:
   6.0.16 at [/root/.dotnet/shared/Microsoft.AspNetCore.App]
  7.0.5 at [/root/.dotnet/shared/Microsoft.AspNetCore.App]

Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failed

To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=5.0.0&arch=x64&rid=ubuntu.23.04-x64

Now my Server shows 503 - Service Unavailable ...

I have tried to Install .NET 5.0 , but it's no longer supported for Ubuntu 23.04, also tried to install .NET 6.0 still the same, I want to find a solution to this error to run my API using Swagger.

答案1

得分: 0

错误提示说您没有安装.NET 5框架,但您安装了更高版本,因此您可以在更高版本上运行它,但必须配置向前滚动行为以供应用程序使用。

请注意,使用此选项让应用程序在不同于其设计的框架版本上运行,可能会导致由于框架版本之间的更改而导致意外行为。

或者,您可以将API的框架版本升级到最新的.NET 7。

英文:

Error says you don't have .NET 5 framework installed, but you have higher versions so you can run it on a higher version, but you must configure roll-forward behavior for the application.

Note that since using this option lets the application run on a different framework version than the one for which it was designed, it may result in unintended behavior due to changes between versions of a framework.

Or you could upgrade the framework version of your API to the latest .NET 7.

huangapple
  • 本文由 发表于 2023年6月13日 18:11:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76463832.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定