【发布时间】:2016-10-27 02:34:25
【问题描述】:
我创建了一个在开发集群上运行的参与者服务。一个 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 吗?
【问题讨论】:
-
当我尝试创建一个 ActorProxy 时,发生了所描述的错误。但与此同时(感谢这篇文章:stackoverflow.com/questions/38015934/…)我了解到,从集群外部的客户端应用程序中使用 ActorProxy 目前不能很好地工作。在同一个 SF 应用程序中使用无状态 WebAPI 服务是一种替代方法(如下所示:github.com/Azure-Samples/…)。