The System.ServiceModel.Channels.ServiceChannel communication object cannot be used for communication because it is in the Faulted state

The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.

I get this error when a Windows application tries to communicate with a WCF hosted as a Windows service through wsDualHttpBinding. WCF is used to communicate with the device through the serial port. The Windows application used to send commands often through the WCF window service.

Here's the stack trace:

stack trace: at System.ServiceModel.Channels.CommunicationObject.ThrowIfDisposedOrNotOpen () in System.ServiceModel.Channels.ServiceChannel.Call (String action, Boolean oneway, operation ProxyOperationRuntime, Object [] ins, Object [], time-out Time] System.ServiceModel.Channels.ServiceChannelProxy.InvokeService (IMethodCallMessage method Call, ProxyOperationRuntime) when System.ServiceModel.Channels.ServiceChannelProxy.Invoke (iMessage message)

Exception thrown in [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage (iMessage reqMsg, IMessage retMsg) in System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke (MessageData & Int3232), type Grid, msgData, type. CommandServiceReference.ICommandService.SendToMultipleChannel (String [] channel, Int32 [] [] locid, String cmd, Int32 cmdData) with GridSplitter.CommandServiceReference.CommandServiceClient.SendToMultipleChannel (String [] channel, Int32 [d] [cmd] ) with GridSplitter.MainWindow.bwChkAndSendRedeploy_DoWork (object sender, DoWorkEventArgs e): 09/11/2012 11:05:58 AM

  • I could not understand why the service goes into a failed state.
  • Should I catch this exception and make some corrections (if recommended)?
  • Can a TCP bundle help me avoid / remove this exception?
+4
source share
1 answer

Your problem is that your code uses an instance of the service proxy (Service Reference generated by SvcUtil or created directly from ChannelFactory ) after the service call caused an error. The WCF method is implemented, you cannot "reuse" the service proxy as soon as a call with this proxy caused an error.

You need to write the correct logic for the exception handling for the lines shown in this good post for specific WCF requirements. This must be done regardless of the actual binding that you configure to use the proxy.

+4
source

Source: https://habr.com/ru/post/1445978/


All Articles