在Service
课程中我有Post
方法:
public void Post(UpdateAdd request)
{
try
{
Service.Db.Insert(some_data);
}
catch (SqlException e)
{
switch (e.Number)
{
case SqlErrorNumbers.UniqueIndex:
throw new UniqueIndexException();
}
}
}
当我点击F5
(调试 - >运行)时,服务代码在catch结束时停止并说:" UniqueIndexException未被用户代码"处理在我的客户端代码中,我必须捕获一般的WebException而不是像文档says here一样的WebServiceException。
我失踪了什么?
如何使新的UniqueIndexException();在调试模式下运行时不要停止我的代码执行,以及如何知道在服务中抛出了UniqueIndexException()。 WebException的InnerException为null。