I have WCF service that sometimes rise Faulted
event on production for yet unknown reasons.
I want to reproduce and test such situation in development environment, but I don't understand how to achieve that.
Faulted
event belongs to System.ServiceModel.Channels.CommunicationObject
and inherit by System.ServiceModel.ServiceHost
that I use to host my WCF service.
I there any way to force my ServiceHost
produce Faulted
event? I tried to manually corrupt client side wcf contract, but it just failed on client side due contract mismatch and service still works properly. Any ideas?
The Failed state does not exist. But, if you are talking about a generic way to close the host you can try:
If a failure is mandatory for you, than the state you're looking for is Faulted. The Host object (whose type is System.ServiceModel.Channels.CommunicationObject) has a method named Fault(), which isn't public, but you'll probably be able to call it with a bit of reflection. That should make the Host transitioning into the Faulted state.
You can also use a host derived from WebServiceHost:
source:Force WCF Host into Faulted State