2012-11-16 34 views
0

我已經部署了我的服務並將Visual Studio附加到進程中以在一個Visual Studio實例中進行調試,而在另一箇中,我有一個以調試模式運行的客戶端控制檯測試應用程序,我可以看到兩種服務方法,調試器,但在第二個我故意拋出異常的情況下,我根本沒有看到ErrorHandlerBehavior中的代碼被調用。 我的ErrorHandlerBehavior註冊不正確?如何獲取WcfFacility和Wcf全局異常處理工作?

我想知道是否需要在我的服務配置中有一個行爲擴展?

我根據我的全局異常處理掉的這example

這裏是我的容器登記在我的服務程序主要方法:

container.AddFacility<WcfFacility>(f => f.CloseTimeout = TimeSpan.Zero); 

    container 
     .Register(Component.For<WcfProtoType.IServiceProtoType>() 
      .ImplementedBy<WcfProtoType.ProtoTypeService>() 
      .Named("ProtoTypeService") 
      .AsWcfService(new DefaultServiceModel() 
       .AddEndpoints(WcfEndpoint 
        .BoundTo(new BasicHttpBinding(BasicHttpSecurityMode.None)) 
        .At(baseUrl) 

        ).PublishMetadata(o => o.EnableHttpGet())),Component.For<ServiceBase>().ImplementedBy<MyService>(), 
        Component.For<ErrorHandlerBehavior>().Attribute("scope").Eq(WcfExtensionScope.Services)); 

回答

0

我看着Castle Windsor源和從我可以告訴EndPointBehavior需要先註冊如下:

container 
    .Register(Component.For<ErrorHandlerBehavior>().Attribute("scope").Eq(WcfExtensionScope.Services), 
     Component.For<WcfProtoType.IServiceProtoType>() 
      .ImplementedBy<WcfProtoType.ProtoTypeService>() 
      .Named("ProtoTypeService") 
      .AsWcfService(new DefaultServiceModel() 
       .AddEndpoints(WcfEndpoint 
        .BoundTo(new BasicHttpBinding(BasicHttpSecurityMode.None)) 
        .At(baseUrl) 
        ).PublishMetadata(o => o.EnableHttpGet())),Component.For<ServiceBase>().ImplementedBy<MyService>());