Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8994017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:19:38+00:00 2026-06-15T23:19:38+00:00

In my WCF WebMethod I have the following code that provides some parameter validation.

  • 0

In my WCF WebMethod I have the following code that provides some parameter validation. It works okay and throws the FaultException:

Public Function BeforeCall(operationName As String, inputs() As Object) As Object Implements IParameterInspector.BeforeCall
    Dim u As MyAppUser = CType(inputs(0), MyAppUser)
    If u.FirstName Is Nothing Then
        Throw New FaultException(Of String)("First Name is Nothing", "First name must be a string value, and not empty.")
    End If
    Return u
End Function

In the consuming application I then call the method in such a way as to trigger the error (to check it works). I catch the error to provide feedback, like this:

Dim u As New ServiceReference1.MyAppUser
u.FirstName = Nothing
u.Surname = "SomeSurname"
Dim i As New ServiceReference1.Service1Client
Dim u2 As New ServiceReference1.MyAppUser
Try
    u2 = i.GetDataUsingDataContract(u)
Catch fe As FaultException
    Trace.Warn("FaultException Caught")
    Trace.Warn(fe.Message)
    Exit Sub
Catch ex As Exception
    Throw
End Try

Within the trace output however, I only see this:

FaultException Caught

First name must be a string value, and not empty.

Can anyone enlighten me please as to how I can read the FaultException detail as well as the reason provided when the FaultException was thrown?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:19:40+00:00Added an answer on June 15, 2026 at 11:19 pm

    To get the exception detail you would create a custom fault contract, which is included in the details of the FaultException. Additionally, you would include the FaultReason when throwing an exception. See the following articles for more information.

    • Fault Handling in WCF Services
    • WCF error handling and some best practices
    • Exception Handling in WCF
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom class library that performs validation. I want to open up
For historical reasons, I have some WSE 3.0 web services that I cannot upgrade
I have a .NET 4.5 WCF client app that uses the async/await pattern to
I have a web service that looks something like this: [ServiceContract] public class MyService
We have a C# Web Service that declares itself using attributes. The code-behind file
I am trying to solve a problem where i have a WCF system that
I'm just learning about WCF WebMethods, and have started to digest the code to
I'm just looking for some general advice with this one please. My WCF WebMethod
Our WCF services occaisionally spawn a worker thread to handle something that the client
In WCF services and a variety of other .NET apps, I understand that app.config

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.