我在WPF中进行了一个应用程序,即获取表单上的数据并将其保存到数据库中(通过数据服务)。如果我在我的机器上和在托管的服务器上这样做,那么服务都能正常工作。但是如果我在另一台机器上做的话,我就会得到DataServiceRequestException。我猜是配置中的一些东西,但例外不是很好。
有办法从那里获得更多的信息吗?
我已经有了:
config.UseVerboseErrors = true;和
[System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)]在我的服务方面。
发布于 2016-06-15 05:15:12
我认为您可以利用服务模型提供的IErrorHandler接口来获取服务操作中出现的所有异常。下面是有关如何调试的代码并找到适当的注释:
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
public class YourService : IErrorHandler
{
public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
{
//Put the break point and monitor the exception.
//or put some log in Handle error method.
}
public bool HandleError(Exception error)
{
//log the exception in this method as it run on separate thread.
return true;
}
}我希望这个回答你的问题。
https://stackoverflow.com/questions/37812985
复制相似问题