Reputation: 675
I'm hosting a service using Windsor's WCF Facility, but I can't get UseSynchronisationContext
and ConcurrencyMode
set that one would normally do using the ServiceBehaviorAttribute
. I've seen two options that apparently should work (but tried both to no avail):
ServiceBehaviorAttribute
as a Component for IServiceBehavior
Description
collection of Behaviors
in the OnCreated
configuration callback in the WCF registration.A third method that I've tried is using AddExtensions
, but that results in an exception because there's already a ServiceBehaviorAttribute
(by default?) in the list of Behaviors. This is also the case with method 2, but in that case I can remove it and add a new one, or modify the existing entry.
It's really frustrating that there doesn't seem any documentation on this except a line stating 'Remove the ServiceBehaviorAttribute' from your services, apparently because it can conflict with the WcfFacility.
Can someone point me on how to properly do this? Any hint is appreciated!
Upvotes: 0
Views: 138
Reputation: 675
Unfortunately I didn't properly test. Modifying the properties of the ServiceBehaviorAttribute
in the list of Behaviors
of the Description
property in the OnCreated
action actually works as intended.
Sample registration:
container.Register(Component.For<IWCFWarehouseServiceAsyncCallback>()
.ImplementedBy<WarehouseService>()
.AsWcfService(new DefaultServiceModel()
.AddBaseAddresses(baseAddress)
.OnCreated(host =>
{
var sb = host.Description.Behaviors.Find<ServiceBehaviorAttribute>();
sb.UseSynchronizationContext = false;
sb.ConcurrencyMode = ConcurrencyMode.Reentrant;
})
.AddEndpoints(WcfEndpoint.BoundTo(binding).At("WarehouseService"))));
Upvotes: 0