本文介绍了WCF 服务中的错误报告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个自托管的 Net Tcp WCF 服务,我有以下方法
I have a self hosted Net Tcp WCF service and I have the following method
Subscribtion GetSubscribtion(int subscribtionId)
{
Subscribtion s;
if (_subscribtionTable.TryGetValue(subscribtionId, out s) == false)
{
Console.WriteLine("Not Found SessionID");//for debugging
throw new ArgumentException("Invalid Subscription Id");
}
return s;
}
抛出异常是在服务编程中报告错误的好习惯吗?
Is throwing exception is a good practice for reporting erros in service programming?
推荐答案
在 WCF 中,您应该改为定义和抛出 FaultException.以下文章提供了示例和详细信息:
In WCF you should instead be defining and throwing a FaultException. The following articles provide examples and details:
这篇关于WCF 服务中的错误报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!