Questions tagged [faultexception]

A FaultException is the type of exception WCF services and clients use to communicate exceptions and optionally their details.

A FaultException is the type of exception WCF services and clients use to communicate exceptions and optionally their details. Quoting from the relevant MSDN documentation page:

In a service, use the FaultException class to create an untyped fault to return to the client for debugging purposes.

In a client, catch FaultException objects to handle unknown or generic faults, such as those returned by a service with the IncludeExceptionDetailInFaults property set to true. Because FaultException extends CommunicationException, remember to catch any FaultException objects prior to catching CommunicationException objects if you want to catch them separately.

125 questions
16
votes
1 answer

client will not catch generic FaultException< T >, only FaultException

I've read all there is to read on this, but maybe I'm missing something (well, definitely I'm missing something otherwise it would be working already) I'm throwing some exception error inside my server business layer: public class RfcException : …
lurscher
  • 25,930
  • 29
  • 122
  • 185
10
votes
2 answers

Unit testing WCF Faults

What's the best way to unit test expected faults from WCF services? I am attempting to unit test a WCF service which is (correctly) throwing FaultExceptions for a certain reproducible error. The unit tests get an instance of the WCF client and call…
mattv
  • 101
  • 1
  • 5
10
votes
5 answers

FaultException.Detail coming back empty

I am trying to catch a given FaultException on a WCF client. I basically need to extract a inner description from the fault class so that I can then package it in another exception for the upper layers to do whatever. I've done this successfully a…
JohnIdol
  • 48,899
  • 61
  • 158
  • 242
9
votes
3 answers

WCF/WebService: Interoperable exception handling

I understand that WCF will convert an exception into a fault and send it back as a SOAP message, but I was wondering if this is truly interoperable. I guess I'm having a tough time trying to figure out this possible scenario: Client (Java) calls a…
michael
  • 14,844
  • 28
  • 89
  • 177
8
votes
1 answer

WCF FaultException Without Sending StackTrace

I have some WCF services with predefined FaultContract attributes. When the FaultException exceptions are thrown, they're sending StackTrace, Source and other potentially unsave information. Is it possible to return only: Detail (from the…
reifnir
  • 143
  • 1
  • 5
8
votes
1 answer

Injecting WCF fault contract using Castle Dynamic Proxy Generation

I am currently working on WPF application with a WCF backend. We have implemented a client logging solution and a server logging solution for exception handling, and they work great, but it is often difficult to tie the information together over…
BernicusMaximus
  • 250
  • 2
  • 13
7
votes
4 answers

WCF - Throw an Exception or FaultException?

What's more efficient? Throwing an exception or throwing a fault... the way I see it is that there's 2 scenarios: An exception occurred and is caught, do you throw that existing Exception or create a new FaultException and throw that? Your own…
michael
  • 14,844
  • 28
  • 89
  • 177
7
votes
2 answers

Abort() method of wcf client proxy doesn't release session after catching FaultException

I have created a simple wcf service hosted in IIS and wcf client and figured out that when u catch a FaultException from the wcf service and then call client.Abort() to release the session (as the microsoft samples said) it doesn't release the…
Sergey Smelov
  • 1,081
  • 3
  • 14
  • 26
5
votes
1 answer

TypeInitializationException: The type initializer for 'vService.CheckService' threw an exception

I am receiving a FaultException from a WCF service as follows when it is invoked: 2012-04-02 16:26:00.3593|Error|System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: The type initializer for 'vService.CheckService' threw an…
Animesh
  • 4,926
  • 14
  • 68
  • 110
5
votes
2 answers

WP7: Unable to catch FaultException in asynchronous calls to WCF service

I am currently developing a Windows Phone 7 App that calls a WCF web service which I also control. The service offers an operation that returns the current user's account information when given a user's login name and…
5
votes
1 answer

WCF custom fault exception not caught correctly in client

I'm trying to create some custom FaultException. I've made a DataContract class called CreateFault. [DataContract] public class CreateFault { private string report; public CreateFault(string message) { this.report = message; …
Johan Björk
  • 101
  • 1
  • 6
5
votes
3 answers

WCF throwing CommunicationException when FaultException is thrown

Solution: A bit of tracing showed the CommunicationException was being thrown because there was an issue with my exception T not serializing correctly; because, two layers deep, I had an anonymously typed object, which was unserializable. Removing…
Andy Hunt
  • 1,053
  • 1
  • 11
  • 26
5
votes
1 answer

Custom Exception as Detail in Fault Exception

I'm trying to throw my own custom exception inside a FaultException from my WCF service and catch it in my WCF client. On the client side, however, the exception is caught as a non-generic FaultException and the details of my custom exception are…
urig
  • 16,016
  • 26
  • 115
  • 184
4
votes
2 answers

Throwing FaultException using Custom Exception Handler EL WCF

So I'm trying to use Enterprise Library in my WCF service to do some of the exception-related work for me. My idea is to set up a "Custom Exception Handler" for say "NullReferenceException" and in the "Custom Exception Handler" create…
4
votes
2 answers

Catch FaultException for any Exception derived TDetail?

How do I catch FaultException for any Exception derived TDetail? I tried catch( FaultException ) {} but that does not seem to work. Edit The purpose is to gain access to the Detail property.
Suraj
  • 35,905
  • 47
  • 139
  • 250
1
2 3
8 9