Cant get the catch statement to catch the custom exception
- by user282807
i have created a custom exception in the business layer and also using wcf layer where I am calling the methods in the business layer then in another website i am calling the method from wcf. i can see the message that i wrote in custom exception but the program goes staright to exception (the second catch block) instead of hitting my first catch block(where the custom exception is) when i hover over the exception i see my message but it's inside something called faultexception which i am not familiar with. and in there under details..there i see type= CanOnlyApplyOnceException. here is my code:
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";
}
}