Unhandled exception using FaultException<T> with WCF and WP7 App

I am consuming a WCF service from a WP7 app. Both are in a single VS solution. Everything worked fine until I tried to pass back a FaultException.

When throwing the FaultException from my WCF service, I receive the message "An unhandled exception of type 'System.ServiceModel.FaultException`1' occurred in System.ServiceModel.dll" on the EndInvoke in my proxy. If I hit continue, the exception does not bubble up. My handler code is never hit.

I believe I have everything wired up properly. I've seen plenty of examples, as I've spent an entire day scouring the web for help with this issue. If I stop throwing the FaultException, my application works fine.

In the VS Debug > Exceptions dialog, I have tried disabling FaultException and FaultException'1 under CLR/System.ServiceModel. I have also tried going to Tools > Options, Debuggung > General and turning off "Enable the exception assistant" and "Enable Just My Code (Managed only). None of these has enabled the exception to bubble up to my calling method in the app.

Interface code --

List<MyResult> GetValues(DateTime beginDate, DateTime endDate);

Exception type --

public class NotAuthorizedException
    public string Message { get; set; }

Server code to throw exception --

throw new FaultException<NotAuthorizedException>(
    new NotAuthorizedException(),
    new FaultReason("Not authorized."),
    new FaultCode("Sender"));

Client call to WCF service --

    MyServiceClient myService = new MyServiceClient();
    myService.GetValuesCompleted += new EventHandler<GetValuesCompletedEventArgs>(myService_GetValuesCompleted);

    myService.GetValuesAsync(DateTime.Now, DateTime.Now.AddMonths(6));
catch (FaultException<NotAuthorizedException>)
    //handle error here

Where it breaks (in Reference.cs) --

System.Collections.ObjectModel.ObservableCollection<Namespace.MyService.MyResult> _result = ((System.Collections.ObjectModel.ObservableCollection<Namespace.MyService.MyResult>)(base.EndInvoke("GetValues", _args, result)));

The proxy code is the unaltered code generated from "Add Service Reference" menu item.

It has to be something simple, but I'm just not seeing it!


I believe you should catch the FaultException<NotAuthorizedException> at myService_GetValuesCompleted instead of where you are doing it now

Need Your Help

Postrgesql running on coreos

postgresql docker coreos

I am running a postgresql 9.4 container on CoreOS and something keeps consuming the drive space. I originally thought it might be an issue with copy on write that was causing the disk to fill up s...

Reload a specific frame from a popup window

javascript jquery internet-explorer popup window

I have a popup window, and from there, I want the parent window to reload, but a specific frame not the entire page.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.