2011-11-18 83 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