2016-06-14 18 views
0

我在WPF中做了一個應用程序,它假設獲取我的表單上的數據並將其保存到數據庫(通過數據服務)。如果我在我的機器上和託管的服務器上執行此操作,則所有服務都可以正常工作。但是如果我在不同的機器上執行DataServiceRequestException。我猜是配置的東西,但例外是不是非常acurate。SaveChanges通過DataService的例外

有沒有辦法從那裏獲得更多信息?

我已經有了:

 config.UseVerboseErrors = true; 

[System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)] 

在我的服務端。

回答

2

我想你可以利用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; 
    } 
} 

我希望這能回答你的問題。