zhihao

Hi All:

I will create a ServiceHost, the problem is how to apply "returnFaults" behavior section

The configuraiotn section:

<behaviors>
<serviceBehaviors>
<behavior name="returnFaults">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true">
</behavior>
<serviceBehaviors>
<behaviors>

Thanks,
Zhihao


Re: Windows Communication Foundation (Indigo) How to apply behavior configuration section in app.config/web.config while coding

Brian McNamara - MSFT

See http://msdn2.microsoft.com/en-us/library/ms730137.aspx but the short answer is

<service ... behaviorConfiguration="returnFaults">

on the <service> element that corresponds to your particular service.






Re: Windows Communication Foundation (Indigo) How to apply behavior configuration section in app.config/web.config while coding

zhihao

The problem is my service is not configed in app.config/web.config. I add my service by host.AddServiceEndpoint. so how to let my service to apply the "returnFaults" section





Re: Windows Communication Foundation (Indigo) How to apply behavior configuration section in app.config/web.config while coding

Brian McNamara - MSFT

In that case, you can just do the same thing imperatively, e.g.
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
host.Description.Behaviors.Add(smb);
host.Description.Behaviors.Find<ServiceDebugBehavior>().IncludeExceptionDetailInFaults = true;

There is no API to use the behavior config apart from the service config (unless you go and read the config file directly yourself).