【问题标题】:Service Fabric fails to find resource fileService Fabric 找不到资源文件
【发布时间】:2019-07-02 11:52:13
【问题描述】:

我在将微服务应用程序部署到 Azure 中的远程 Service Fabric 集群时遇到问题。

应用程序由 5 个服务组成,其中 4 个已成功启动,它们的状态显示为 Ready。但是一个失败并出现以下错误(所有节点上的状态在InBuildError 之间变化):

'System.RA' reported Warning for property 'ReplicaOpenStatus'.
Replica had multiple failures during open on _nt1bm_5. API call: 
IStatelessServiceInstance.Open(); Error = 
System.Resources.MissingManifestResourceException (-2146233038)
Could not find any resources appropriate for the specified culture or the 
neutral culture.  Make sure 
"Microsoft.ServiceFabric.Services.Communication.AspNetCore.SR.resources" was 
correctly embedded or linked into assembly 
"Microsoft.ServiceFabric.AspNetCore" at compile time, or that all the 
satellite assemblies required are loadable and fully signed.
at System.Resources.ManifestBasedResourceGroveler.HandleResourceStreamMissing(String fileName)
   at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)
   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
   at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
   at Microsoft.ServiceFabric.Services.Communication.AspNetCore.AspNetCoreCommunicationListener.GetEndpointResourceDescription(String endpointName)
   at Microsoft.ServiceFabric.Services.Communication.AspNetCore.KestrelCommunicationListener.GetListenerUrl()
   at Microsoft.ServiceFabric.Services.Communication.AspNetCore.AspNetCoreCommunicationListener.OpenAsync(CancellationToken cancellationToken)
   at Microsoft.ServiceFabric.Services.Runtime.StatelessServiceInstanceAdapter.OpenCommunicationListenersAsync(CancellationToken cancellationToken)
   at Microsoft.ServiceFabric.Services.Runtime.StatelessServiceInstanceAdapter.System.Fabric.IStatelessServiceInstance.OpenAsync(IStatelessServicePartition partition, CancellationToken cancellationToken)
For more information see: https://aka.ms/sfhealth 

一些注意事项:

  • 所有服务使用几乎完全相同的主机初始化(端口不同)
  • 应用程序配置为仅使用 HTTPS
  • 使用 .NET Core 2.2 编写的应用程序
  • 当前的 Service Fabric 版本是 6.4.637.9590
  • 主机的操作系统是 Windows Server(可能是 2012 年)
  • 在本地集群上,它工作得很好
  • 使用 .NET Core 自托管,一切正常

可能是什么原因造成的?

如何调试此类错误?

Service Fabric 的源代码是否可以在某处查看失败的代码?

如果您需要任何其他信息,请询问:)

【问题讨论】:

  • SF 源代码可在 github 上找到,但它是 C++ 和跨平台的,而且很难慢下来。我怀疑这会带你到任何地方。试试这个可能吗? github.com/Microsoft/aspnet-api-versioning/issues/331
  • 尝试将软件包更新到 3.3.638 版本,有一些 issues 包含最新版本的软件包。

标签: .net-core azure-service-fabric service-fabric-stateless


【解决方案1】:

我找到了这个错误的原因!

即这个错误:

Could not find any resources appropriate for the specified culture or the 
neutral culture.

在解决方案中,我们有特殊的项目结构:

  • 源代码:

    • 自托管项目(.NET Core 应用,所有控制器都在这里,Startup 等也在这里)
    • Service Fabric 主机(它使用控制器并从自托管项目启动,有单独的 Program.cs 和 Web 主机构建器 - 适用于 Service Fabric)

两个项目都有不同的appsettings.json - 但名称相同(!!!

使用 Visual Studio 在本地构建和打包时一切正常,但在 Azure DevOps 上构建时(不管使用的构建类型:dotnet buildVisual Studio build)会出现奇怪的错误。

在为部署创建的包中(使用 -t:Package 构建 .sfproj)即使我们引用 ServicFabric 项目 appsettings.json 有时也取自自托管项目。 (与 ServiceFabric 项目中的 appsettings.json 不同)错误来自尝试读取 appsettings.json 中不存在的条目

TLDR;

错误来自于尝试读取 appsettings.json 中不存在的条目

我们当前的解决方案是为来自不同项目的appsettings.json 使用不同的名称。如果我们找到更好的解决方案,我会更新答案。也将不胜感激有关此问题的任何帮助。

【讨论】:

    猜你喜欢
    • 2016-02-22
    • 2021-04-12
    • 2018-04-27
    • 2023-04-07
    • 2019-11-07
    • 1970-01-01
    • 1970-01-01
    • 2020-05-20
    • 2020-03-08
    相关资源
    最近更新 更多