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?
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).
Some example code. Its in VB, but any C# help would also be greatly appreciated.
<ServiceContract(Name:="API", NameSpace:="urn:test")>
Public Interface IWebServiceApi
<OperationContract()>
<WebGet(UriTemplate:="GetObject")>
Function Api_Root() As Object
End Interface
<ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerCall, IncludeExceptionDetailInFaults:=True)>
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