tags:

views:

394

answers:

2

Hi! I have a WCF service that I secure with a custom UserNamePasswordValidator and Message security running over wsHttpBinding. The release code works great. Unfortunately, when I try to run in debug mode after having previously used invalid credentials (the current credentials ARE valid!) VS2008 displays an annoying dialog box (more on this below).

A simplified version of my Validate method from the validator might look like the following:

    public override void Validate(string userName, string password)
    {
        if (password != "ABC123")
            throw new FaultException("The password is invalid!");
    }

The client receives a MessageSecurityException with InnerException set to the FaultException I explictly threw. This is workable since my client can display the message text of the original FaultException I wanted the user to see.

Unfortunately, in all subsequent service calls VS2008 displays an "Unable to automatically debug..." dialog. The only way I can stop this from happening is to exit VS2008, get back in and connect to my service using correct credentials. I should also add that this occurs even when I create a brand new proxy on each and every call. There's no chance MY channel is faulted when I make a call. Its likely, however, that VS2008 hangs on to the previously faulted channel and tries to use it for debugging purposes.

Needless to say, this sucks! The entire reason I'm entering "bad" credentials is to test the "bad-credential" handling.

Anyway, if anyone has any ideas as to how I can get around this bug (?!?) I'd be very very appreciative....

A: 

I'm starting to think that the problem has to do with proxy closure. I just saw an excellent set of WCF video's from Michele Leroux Bustamante (http://wcfguidanceforwpf.codeplex.com) that makes me think the problem may be in my client code. I'll give it a go today and report back how it did....

lsb
OK, I finally figured out what was going on. Basically, I had problems with not closing my proxy on the client side in a timely matter (i.e. letting the proxy be closed by garbage collection). See http://wcfproxygenerator.codeplex.com for a good solution to the problem...
lsb
A: 

Hi lsb,

Can I ask how you set the FaultContract? I have created a service method and added the FaultContract there, but when I throw an exception much like you do, it isn't getting propogated to the client.

I am using Silverlight 4 and its WCF stack, but I have already gotten around the fault contract and got it to work on non authenticated calls, but as soon as I use my UserNamePasswordValidator I am unsure where to put the FaultContract if it needs to somewhere else.

Cheers

AD