I have a WCF service that throws an exception that I am trying to catch in my silverlight client code. I am using Undeclared Faults for Debugging, and this is my maintenance method:
[OperationContract]
public ServiceResponse MyWCFServiceMethod()
{
ServiceResponse resp = new ServiceResponse ();
throw new FaultException(new FaultReason(new FaultReasonText("My fault Reason!")),new FaultCode("my fault code here"));
return resp;
}
Now in my silverlight client view model in the service callback method, I try to process it like this:
private void MyServiceCallback(MyWCFServiceMethodCompletedEventArgs e)
{
if (e.Error == null)
{
}
else if (e.Error is FaultException)
{
FaultException<ExceptionDetail> fault = e.Error as FaultException<ExceptionDetail>;
MessageBox.Show(fault.Detail.Message);
MessageBox.Show(fault.Reason.ToString());
}
}
on this line else if (e.Error is FaultException)I still get a System.Net.WebException {The remote server returned an error: NotFound.}
These are configuration entries
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
This is a class of service ad.
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class MySilverlightWCFService
{
....
This service is in another project within the same silverlight solution. Why can't my Silverlight client get an exception exception that I throw?
Thank you for your time...
source