生产服务器上的 Azure Service Fabric 缺少 DLL:FabricCommon.dll

Azure Service Fabric missing DLL on production server: FabricCommon.dll

我创建了一个在开发集群上运行的参与者服务。 ASP.NET 应用程序(通过 IIS 单独托管)连接到集群并使用参与者。这很好用。

但是当我将所有内容部署到生产环境时,ASP.NET 应用程序无法连接到集群,出现以下异常。集群在本地托管 (Windows 2012 R2)。

The type initializer for 'Microsoft.ServiceFabric.Services.ServiceTrace' threw an exception.

Stacktrace:
   at Microsoft.ServiceFabric.Services.Common.FabricServiceConfig.TryGetConfigPackageObject(String configPackageName, ConfigurationPackage& package)
   at Microsoft.ServiceFabric.Services.Common.FabricServiceConfig.GetSettingsFilePath(String configPackageName)
   at Microsoft.ServiceFabric.Services.Common.FabricServiceConfig.GetConfig()
   at Microsoft.ServiceFabric.Services.Common.FabricServiceConfigSection.Initialize()
   at Microsoft.ServiceFabric.Services.Communication.FabricTransport.Common.FabricTransportSettings.LoadFrom(String sectionName, String filepath, String configPackageName)
   at Microsoft.ServiceFabric.Services.Communication.FabricTransport.Common.FabricTransportSettings.TryLoadFrom(String sectionName, FabricTransportSettings& settings, String filepath, String configPackageName)
   at Microsoft.ServiceFabric.Services.Communication.FabricTransport.Common.FabricTransportSettings.GetDefault(String sectionName)
   at Microsoft.ServiceFabric.Actors.Remoting.FabricTransport.FabricTransportActorRemotingProviderAttribute.CreateServiceRemotingClientFactory(IServiceRemotingCallbackClient callbackClient)
   at Microsoft.ServiceFabric.Actors.Client.ActorProxyFactory.CreateServiceRemotingClientFactory(Type actorInterfaceType)
   at Microsoft.ServiceFabric.Actors.Client.ActorProxyFactory.GetOrCreateServiceRemotingClientFactory(Type actorInterfaceType)
   at Microsoft.ServiceFabric.Actors.Client.ActorProxyFactory.CreateActorProxy[TActorInterface](Uri serviceUri, ActorId actorId, String listenerName)
   at Microsoft.ServiceFabric.Actors.Client.ActorProxy.Create[TActorInterface](ActorId actorId, Uri serviceUri, String listenerName)

Inner Exception:
innerExceptionType: System.DllNotFoundException
innerStacktrace:
   at System.Fabric.Interop.NativeCommon.FabricGetConfigStore(Guid& riid, IFabricConfigStoreUpdateHandler updateHandler)
   at System.Fabric.Common.NativeConfigStore.CreateHelper(IFabricConfigStoreUpdateHandler updateHandler)
   at System.Fabric.Interop.Utility.WrapNativeSyncInvoke[TResult](Func`1 func, String functionTag, String functionArgs)
   at System.Fabric.Interop.Utility.RunInMTA[TResult](Func`1 func)
   at Microsoft.ServiceFabric.Common.Tracing.Trace.InitializeFromConfigStore()
   at Microsoft.ServiceFabric.Services.ServiceTrace..cctor()
innerExceptionMessage: Unable to load DLL 'FabricCommon.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
exceptionType: System.TypeInitializationException

似乎无法在 Web 服务器(托管 ASP.NET)上找到 FabricCommon.dll

我发现这个文件是集群安装包的一部分。在开发机器和集群机器上,该文件位于此处:C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code\FabricCommon.dll。但它显然不是通过 NuGet 在客户端应用程序中安装的依赖项。

我是否错过了在 Web 服务器上安装任何先决条件?我必须手动包含 DLL 吗?

我认为您需要在 Web 服务器上安装 Service Fabric SDK。

请参阅下面的 link: https://azure.microsoft.com/en-us/documentation/articles/service-fabric-get-started/

我曾在我的开发机器中发生过这种情况。我所做的只是重新安装 Service Fabric SDK。

将以下 Service Fabric bin 路径添加到您的 PATH 环境变量中:

set PATH=%PATH%;C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code 

同时将执行策略设置为不受限制:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force -Scope CurrentUser 

对于无法在目标环境中安装 Service Fabric SDK 的情况,可以选择使用 Service Fabric REST API

这是 my repo 和用 C# 编写的 API 客户端,可以使用此 API

解析服务

我遇到了同样的问题。重新启动我的机器解决了这个问题。