【发布时间】:2011-12-12 03:30:16
【问题描述】:
我正在为 WCF ChannelFactory 管理器编写一些代码。我的问题来自事件“ChannelFactory.Faulted”:两个参数(“object sender”和“EventArgs args”)都不包含有关原始 fualt 的信息,如何在自定义故障处理程序中获取 ChannelFactory 故障详细信息?
private ChannelFactory CreateFactoryInstance<T>(string endpointConfigurationName, string endpointAddress)
{
ChannelFactory factory = null;
factory = new ChannelFactory<T>(endpointConfigurationName, new EndpointAddress(endpointAddress));
//Customizing Factory Fault handler
factory.Faulted += FactoryFaulted;
factory.Open();
return factory;
}
private void FactoryFaulted(object sender, EventArgs args)
{
ChannelFactory factory = (ChannelFactory)sender;
factory.Close();
//...
//How can I get more Fault detail, so as to throw a meaningful Exception?
throw new ApplicationException("Failure in ChannelFactory ");
}
感谢您的关注。
【问题讨论】: