Frank Wang's inspirations on .NET

IEnumerable<Inspiration> inspirations = from i in DataContext.Inspirations where i.Sharable == true select i

IncludeExceptionDetailInFaults in WCF service configuration

Wednesday, March 12, 2008 12:46 PM

Often times you have some errors in your WCF service that are not detected until the runtime. It can be very frustrating when you receive "server was unable to process request due to an internal error" but you don't know what exactly is going on.

Exception

If you get the error screen above, go ahead and turned on the IncludeExceptionDetailInFaults in the service configuration file. It's set to "false" by default when Visual Studio generates the configuration file.

<behaviors>
            <serviceBehaviors>
                <behavior name="ServiceGatewayBehavior">
                    <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
                    <serviceMetadata httpGetEnabled="true"/>
                    <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
                    <serviceDebug includeExceptionDetailInFaults="true"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>

 

Restart the debugging again and you will see the exact details of the internal error. Although this configuration is helpful for the debugging, you should always turn if OFF before the service goes alive.



  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Feedback

# re: IncludeExceptionDetailInFaults in WCF service configuration

You have mentioned that this setting should be turned off when service goes alive. Is that just to prevent showing internal errors or does it affect the performance of the service. 3/12/2009 4:58 AM | Rohan

# re: IncludeExceptionDetailInFaults in WCF service configuration

You always set it to false before you go online. If you don't, you (third party) get detailed information about your implementation of the webervices. So that is a serieus security risk! 12/7/2009 4:55 AM | LockTar

# re: IncludeExceptionDetailInFaults in WCF service configuration

I understand that is important not to show to third party information about errors in our services in production but ... then how I can catch these errors to see the source of the problem in production, there is a framework or something like that to help in this situation?. Thank you for your post, it helped me because im starting to see this topic :) 7/18/2010 11:15 AM | Jose Gutierrez

# re: IncludeExceptionDetailInFaults in WCF service configuration

hi Guys,
i got the same error then i set
includeExceptionDetailInFaults="true" then it show the another error that the service could not find my table ..
why it is show that error please tell me ...


thanks in advance..
Regords
Victor...
12/13/2010 4:46 AM | victor

# re: IncludeExceptionDetailInFaults in WCF service configuration

Thanks a lot.... This help us to sort one of time bound issues :)


Great Help!!! 1/13/2011 4:46 AM | Pavan Kumar

# re: IncludeExceptionDetailInFaults in WCF service configuration

thanks for sharing this!

by Os cachorros 4/12/2011 12:32 PM | melhor amigo

Post a comment