PrepAway - Latest Free Exam Questions & Answers

What should you do?

You are implementing a Windows Communication Foundation (WCF) service contract named lContosoService in a class named ContosoService.
The service occasionally fails due to an exception being thrown at the service.
You need to send the stack trace of any unhandled exceptions to clients as a fault message. What should you do?

PrepAway - Latest Free Exam Questions & Answers

A.
In the application configuration file on the client, add the following XML segment to the system.serviceModel/behaviors configuration section group.
<endpointBehaviors>
<behavior name=”debug”>
<callbackDebug includeExceptionDetaillnFaults=”true” />
</behavior>
</endpointBehaviors>
Associate the debug behavior with any endpoints that need to return exception details.

B.
In the application configuration file on the service and all the clients, add the following XML segment to the system.diagnostics/sources configuration section group.
<source name=”System.ServiceModel” switchValue=”Error” propagateActivty=”true”>
<listeners>
<add name=”ServiceModelTraceListener” initializeData=”appntracelog.svclog” type=”System.Diagnostics.XmlWriterTraceListener” />
</listeners>
</source>

C.
Apply the following attribute to the ContosoService class.
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]

D.
For each OperationContract exposed by lContosoService, apply the following attribute.
[FaultContract(typeof(Exception))]

Explanation:
ServiceBehaviorAttribute.IncludeExceptionDetailInFaults Property

Gets or sets a value that specifies that general unhandled execution exceptions are to be converted into
a System.ServiceModel.FaultException<TDetail> of type System.ServiceModel.ExceptionDetail and sent as a fault message.
Set this to true only during development to troubleshoot a service.

4 Comments on “What should you do?


Leave a Reply