一、现象
将在windows开发环境下正常运行的.net core webapi程序部署到centOS下,调用部分API时出现500错误。
二、环境
- .NET Core 3.1
- CentOS 8.2
- Supervisor 4.2
三、问题解决
1.查看日志文件
因为通过Supervisor 监控,根据Supervisor 配置文件,找到日志文件。
stderr_logfile=/var/log/supervisor/Sudo.Sms.WebApi.err.log ; 错误日志文件
stdout_logfile=/var/log/supervisor/Sudo.Sms.WebApi.out.log; 输出日志文件
发现输出日志文件中有如下问题:
Connection id “0HM4EIP97R2BN”, Request id “0HM4EIP97R2BN:00000001”: An
unhandled exception was thrown by the application.
System.IO.FileNotFoundException: Could not load file or assembly
‘System.Private.ServiceModel, Version=4.1.2.4, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a’. The system cannot find the file
specified.File name: ‘System.Private.ServiceModel, Version=4.1.2.4,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’
2.问题分析
问题比较简单,就是找不到文件。但问题为何找不到这个文件呢?原来是webapi中通过soap方式调用了其他web service。SoapCore依赖于该文件。
3.解决方式
在webapi发布目录(“netcoreapp3.1\publish\runtimes\unix\lib\netstandard2.0”)下, 可以找到System.Private.ServiceModel.dll文件,上传到该webapi站点下根位置即可。
四、总结
- 发布webapi时,根据目标操作系统,runtimes目录下相应系统的文件也需要发布。
参考文件
- 运行时azure app服务中缺少System.Private.ServiceModel:https://www.javaroad.cn/questions/334545
- https://github.com/dotnet/wcf/issues/2349
421




被折叠的 条评论
为什么被折叠?



