2016-03-21 42 views
0

我正在使用Windsor的WCF設施託管服務,但我無法獲得UseSynchronisationContextConcurrencyMode設置,通常會使用ServiceBehaviorAttribute。我已經看到了,顯然應該工作(但嘗試都無濟於事)兩個選項:Windsor WcfFacility:設置ServiceBehavior屬性

  1. 註冊ServiceBehaviorAttributeIServiceBehavior
  2. 分量修改Description收集BehaviorsOnCreated配置回調在WCF註冊。

,我已經使用AddExtensions嘗試第三種方法,但結果是一個例外,因爲已經有一個在行爲列表中選擇一個ServiceBehaviorAttribute(默認?)。方法2也是這種情況,但在這種情況下,我可以刪除它並添加一個新的或修改現有的條目。

真的很令人沮喪,除了一行聲明'從服務中刪除ServiceBehaviorAttribute'的行外,似乎沒有任何文檔,顯然是因爲它可能與WcfFacility衝突。

有人可以指出我如何正確地做到這一點?任何提示表示讚賞!

回答

0

不幸的是我沒有正確測試。修改OnCreated操作中的Description屬性的列表的屬性Behaviors實際上按預期工作。

樣品登記:

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"))));