In a WCF application we have a servicecontract with attributes:
namespace We.Work {
[ServiceContract(Namespace = "We", Name = "IWork", SessionMode = SessionMode.NotAllowed)]
public interface IWork
an implementation of the servicecontract with attributes:
namespace We.Work {
[ServiceBehavior(Name = "Work", Namespace = "We",
IncludeExceptionDetailInFaults = true,
InstanceContextMode = InstanceContextMode.PerCall,
ConcurrencyMode = ConcurrencyMode.Multiple,
ReleaseServiceInstanceOnTransactionComplete = false
)]
public class WorkImplementation : IWork
a servicehost (windows service or console application for development)
namespace We.Host {
// ....
workServiceHost = new ServiceHost(typeof(We.Work.WorkImplementation));
workServiceHost.Faulted += new EventHandler(Host_Faulted);
workServiceHost.Open();
and last but not least an app.config:
<service behaviorConfiguration="WorkServiceBehaviour" name="We.Work.WorkImplementation">
<endpoint behaviorConfiguration="WorkEndPointBehaviour" binding="wsHttpBinding" bindingConfiguration="WorkWsHttpBindingConfig" name="WorkEndPoint" contract="We.Work.IWork"/>
<host> <baseAddresses> <add baseAddress="http://.../Work.svc"/> </baseAddresses> </host>
</service>
<behaviors>
<endpointBehaviors>
<behavior name="WorkEndPointBehaviour">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="WorkServiceBehaviour">
<serviceDebug httpHelpPageEnabled="true" httpsHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceMetadata/>
<serviceThrottling maxConcurrentCalls="25" maxConcurrentSessions="25" maxConcurrentInstances="25"/>
</behavior>
</serviceBehaviors>
</behaviors>
Questions: Is it possible to mix app.config and attributes, which configuration has precendence, what is a good practice?
E.g. does ServiceContract(SessionMode = SessionMode.NotAllowed) prevent wsHttpBinding from using sessions?
[Answered: how can I be sure the settings in app.config are really applied -- the fully qualified name works.]