I have many webservices running in my project but something odd has been happening for quite some time. My services occasionally crash for no reason with an error message "The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state." This usually happens when I run the application first thing in the morning after which they occur less frequently. Any ideas as to what might be causing this error?
WCF at Services faulted state
wcf
Best Answer
If a WCF service throws a
FaultException
, the client will have its state changed toCommunicationState.Faulted
. If you then try to use this client object to call another service operation, you'll get the errorYou might also get this error if you try to call the
Close()
method on a faulted client, I can't remember.You can check the state of your client object by checking the
State
property. If you want to close your client properly (which you should be doing), you need to call theAbort()
method if the client is in theFaulted
state, and theClose()
method if the client is in any other state.