title: Force WCF Host into Faulted State
body: <p>Is there a way to force a WCF Host to fault? (More specifically a REST based WCF Host.)
  Is there an Exception type that can be thrown that will cause the host to fault?
  If an exception can't get the host into a faulted state, what could?</p>
  
  <p>In the "Api_Root" function below, I've thrown several different types of exceptions, and they either get caught by the exception handler, or cause the whole process to fail(OutOfMemoryException).</p>
  
  <p>Some example code. Its in VB, but any C# help would also be greatly appreciated.</p>
  
  <pre><code>&lt;ServiceContract(Name:="API", NameSpace:="urn:test")&gt;
  Public Interface IWebServiceApi
  
      &lt;OperationContract()&gt;
      &lt;WebGet(UriTemplate:="GetObject")&gt;
      Function Api_Root() As Object
  
  End Interface
  
  &lt;ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerCall, IncludeExceptionDetailInFaults:=True)&gt;
  Public Class WebServiceApi
      Implements IWebServiceApi
  
      Public Function Api_Root() As Object Implements IWebServiceApi.Api_Root
  
          //Throw Exception type that causes the Host to Fail
  
          Return New Object()
      End Function
  
  End Class
  
  Function StartService()
  
      _Service = New WebServiceHost(GetType(WebServiceApi), baseAddresses)
  
      _Service.Open()
  
      AddHandler _Service.Opened, AddressOf Me.Opened
      AddHandler _Service.Closed, AddressOf Me.Closed
      AddHandler _Service.Faulted, AddressOf Me.Faulted
  
  End Function
  
  Sub Faulted(sender As Object, e As EventArgs)
  
      //Handle the falted service here
  
  End Sub
  </code></pre>