首页 文章

运行时azure app服务中缺少System.Private.ServiceModel

提问于
浏览
1

我正在尝试将asp.net core 2.1 webapp部署到azure app服务 . webapp使用wcf服务,因此包含对wcf的引用 . 在编译和开发人员机器上一切运行良好 . 但是,当它部署到azure app服务时,webapp无法启动 . 它抛出一个错误

Could not load file or assembly 'System.Private.ServiceModel, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

我尝试发布自包含和框架相关的应用程序 . 我需要一些特殊的方式来包含或引用这个包吗?

1 回答

  • 1

    尝试在ASP.NET Core 2.1应用程序中使用SoapCore NuGet包后,我遇到了类似的解决方案 . 在Windows 10上本地运行良好但在我发布到Azure之后给出了与原始海报完全相同的堆栈跟踪 . 以下GitHub问题帮助我理解了这个问题:

    https://github.com/dotnet/wcf/issues/2349

    对我来说,SoapCore引用了 System.ServiceModel.Http 4.4.0 ,它依赖于 System.Private.ServiceModel 4.4.0 . 如果您下载NuGet包并打开 System.Private.ServiceModel 4.4.0 的nupkg文件并观察"runtimes"子文件夹,"win7" RID不包含'll see it only lists 2792718 and 2792719 . Azure appears to be looking for runtimes 2792720 or 2792721 , and the GitHub issue above explains how those RID' . 看到问题已经关闭,我下载了 System.Private.ServiceModel 4.5.0 以检查"runtimes"子文件夹并看到它已从"win7"更改为"win",就像在GitHub问题中提到的那样 .

    为了解决我的问题,我直接为我的项目添加了 System.ServiceModel.Http 4.5.0 的依赖项 . 这包括 System.Private.ServiceModel 4.5.0 的较新依赖项,Azure将正确识别"win"运行时,以确保在发布时我的应用程序包含必要的DLL .

相关问题