我使用温莎的WCF设施托管一个服务,但我无法获得通常使用UseSynchronisationContext和ConcurrencyMode设置的ServiceBehaviorAttribute。我看到了两种显然应该有效的选择(但这两种方法都失败了):
ServiceBehaviorAttribute注册为IServiceBehavior组件Description配置回调中的Behaviors集合。我尝试过的第三种方法是使用AddExtensions,但这会导致异常,因为已经有了ServiceBehaviorAttribute (默认情况下?)在行为列表中。方法2也是如此,但在这种情况下,我可以删除它并添加一个新条目,或者修改现有的条目。
非常令人沮丧的是,除了从您的服务中删除ServiceBehaviorAttribute的一行之外,没有任何关于这方面的文档,这显然是因为它可能与WcfFacility冲突。
有人能指点我该怎么做吗?任何提示都是感激的!
发布于 2016-03-22 08:06:56
不幸的是我没做好测试。在ServiceBehaviorAttribute操作的Description属性的Behaviors列表中修改OnCreated属性的属性实际上是按预期工作的。
样本登记:
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"))));https://stackoverflow.com/questions/36139255
复制相似问题