我拋出未處理的DataServiceExceptions(它們由WCF自動處理)返回未授權訪問的狀態代碼等。如何防止Visual Studio在這些未處理的異常中斷?WCF阻止調試器在DataServiceException中破壞
if (!System.Web.Security.Roles.IsUserInRole("Users"))
{
throw new DataServiceException((int)HttpStatusCode.Unauthorized, "You do not have access to this resource.");
}
「我用未處理DataServiceExceptions」,「他們是由WCF自動處理「,」打破這些未處理的例外「。所以基本上你正在處理它呢?你是否抓住了聲明?或只是扔它? – 2013-02-20 07:08:02
請更新您的代碼... – 2013-02-20 07:28:55
我只是拋出新的DataServiceException(401,「錯誤...」)。 WCF自動解包並將格式化的錯誤消息發送給客戶端,但Visual Studio仍在我的代碼中斷行。根本沒有try..catch。 – Monstieur 2013-02-20 07:42:16