0

We are experiencing different behavior on our clients when handling FaultExceptions thrown by our WCF service depending on the version of .NET framework.

The service defines a custom fault:

[DataContract]
public class MyFault
{
    [DataMember]
    public int MyId { get; set; }
}

The interface of the service:

[ServiceContract]
public interface IMyService
{
    [OperationContract]
    [FaultContract(typeof(MyFault))]
    MyResponse DoSomething(MyRequest request);
}

The client handles the exception:

try 
{
    client.DoSomething(myrequest);
} 
catch (FaultException<MyFault> ex) 
{
    ...
}

On a .NET 4.5 machine he will recognise the fault as FaultException<MyFault> and handle it as expected.

However, on a .NET 4 machine he will treat the fault as FaultException (non-generic), so the catch is never reached.

We captured the traffic on the machines to see if there are differences in the communication. Both, request and response are identical. We even updated a .NET 4 machine to .NET 4.5 (without updating any other software or our client software) and the behavior changed.

Is there any logical explanation?

turbophi
  • 151
  • 2
  • 8
  • 3
    [I guess officially... no](http://msdn.microsoft.com/en-us/library/dd456789.aspx). – ta.speot.is Apr 18 '13 at 09:01
  • in my app it works fine in .net 4. show more code for clarification. – ilansch Apr 18 '13 at 20:13
  • I am from Microsoft .NET Framework team. I would like to understand this better. Could you us sample app that can reproduce this issue? Just email us at netfx45compat at Microsoft dot com. Thanks, Varun – Varun Apr 23 '13 at 04:40
  • @turbophi, I am not able to reproduce this issue and I find 4.0 & 4.5 behaviors look same. If you are still able to reproduce this could you send a stand alone repro to the email that Varun (previous comment) has mentioned? – Praburaj Jun 03 '13 at 21:41
  • I wasn't able to reproduce the problem back in April when I extracted it to a small project to provide to the public. However, today we found a similar behavior when we were trying to deserialize a message on a .NET 4 machine. This failed, while the same code was working on a .NET 4.5 machine. We found http://stackoverflow.com/questions/14689305/serialization-breaks-in-net-4-5 which has the opposite behavior (working in 4, not in 4.5). We were able to reproduce this one and will send it to MS. We think that these problems are linked, as the FaultException might be deserialized in a wrong way. – turbophi Jun 06 '13 at 08:13
  • @turbophi - What was the outcome finally? – hB0 Jul 23 '18 at 05:59
  • I was in touch with Microsoft developers, they confirmed the problem and patched it for later builds of the 4.5 version. – turbophi Mar 04 '19 at 10:25

0 Answers0