2011-11-18 38 views
1

我想捕獲一個異常,然後調用正在運行的WCF通道工廠的Abort方法,但我不確定如何去做?如何在使用spring.net wcf創建服務時調用WCF service.Abort():channelfactory

例如

<wcf:channelFactory id="ShoppingService" 
    channelType="solution.TShoppingService, solution" 
    endpointConfigurationName="ServiceEndPoint" /> 

服務處於中止狀態。

我得到儘可能

IApplicationContext context = ContextRegistry.GetContext(); 
context["TShoppingService]... 

服務的參考,但我怎麼調用中止方法?

+2

不熟悉spring.net,但不能投你的服務參考'ICommunicationObject'和調用'中止()'? – Tim

回答

1

Tim的解決方案的工作原理:

((System.ServiceModel.ICommunicationObject)context["ShoppingService"]).Abort(); 
+0

如果我在global.asax應用程序錯誤事件中這樣做,那麼如果用戶導航回來,我將如何重新設置通道工廠? – InfoLearner