我已經創建了業務層自定義異常,並利用我在哪裏調用業務層的方法,然後在另一個網站我打電話從WCF方法WCF層。我可以看到我在自定義異常中寫入的消息,但是當我將鼠標懸停在異常情況下時,我看到了我的消息,但是該程序在異常情況下(第二個catch塊)而不是點擊第一個catch塊(自定義異常)裏面有一些我不熟悉的faultexception。並在那裏的細節..在這裏我看到類型= CanOnlyApplyOnceException。這裏是我的代碼:不能得到catch語句捕捉自定義異常
protected void AddNewApplication()
{
try
{
using (var proxy = new ServiceReference1.ServiceClient())
{
proxy.AddApplication(new Application
{
Credentials = 2,
Comments = txtComments.Text,
});
}
}
catch (CanOnlyApplyOnceException c)
{
ErrorSummary.AddError(c.Message, this);
return;
}
catch (Exception)
{
lblStatus.Text = "There has been an error. Please try again";
}
}
當你看到一個類型,你是不熟悉的,做的第一件事就是檢查MSDN。 – SLaks 2010-03-12 02:32:15
我這樣做,花時間做什麼,我在MSDN中找到,但沒有工作 – user282807 2010-03-12 02:37:11
他們說的不是拋出這樣的:拋出新Canonlyapplyoneexception不拋出新的FaultException(新canonlyapplyonceexception(消息)......我做到了但didnt解決問題 –
user282807
2010-03-12 02:39:26