自托管的WCF net.tcp服务应用程序无法间歇启动

时间:2018-09-18 21:47:06

标签: c# wcf self-hosting etw net.tcp

我们有一个监听WCF端口的Windows服务。该服务将启动,并可能在25%的时间内成功绑定到端口。这是在2台不同的计算机上发生的。这段代码已经稳定了一段时间,唯一的区别可能是我们回来时将其重新定位到.NET 4.6.2,但是我们不确定是否与此有任何关系。当失败时,我们得到以下信息:

System.IO.FileLoadException: Could not load file or assembly 'System.ServiceModel.Internals, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Provider type not defined. (Exception from HRESULT: 0x80090017)
File name: 'System.ServiceModel.Internals, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
   at System.ServiceModel.Diagnostics.TraceUtility.SetEtwProviderId()
   at System.ServiceModel.ServiceHostBase..ctor()
   at System.ServiceModel.ServiceHost..ctor(Object singletonInstance, Uri[] baseAddresses)
   at PSC.Tools.Communication.ListeningExecutorServerWCF.OnStart()

=== Pre-bind state information ===
LOG: DisplayName = System.ServiceModel.Internals, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///D:/FieldAssist/Server/binaries/Links/
LOG: Initial PrivatePath = NULL
Calling assembly : System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.ServiceModel.Internals, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Binding succeeds. Returns assembly from C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Internals\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Internals.dll.
LOG: Assembly is loaded in default load context.

从绑定日志信息中可以看到,它确实看起来像成功解析了程序集。有人有什么想法吗?

引发异常的代码行是:

ServiceHost serviceHost = new ServiceHost(serviceInstance);

其中serviceInstance是类的实例(因此我们建立了一个单例)。

0 个答案:

没有答案