I am a new ASP.net developer and I am trying to do add proper exception handling in my simple 3-tier web-based application. By following this post , I have done, for example, the following in the Data Access Layer (DAL) and the User Interface (UI):
DAL:
public IEnumerable<Survey> getData()
{
List<Survey> surveysList = new List<Survey>();
try
{
using (ItemsDBEntities context = new ItemsDBEntities())
{
surveysList = (from survey in context.Surveys
select new Survey()
{
ID = survey.ID,
startDate = survey.StartDate,
EndDate = survey.EndDate,
Description = survey.Description
}).ToList();
}
}
catch (EntityException ex)
{
//something wrong about entity
throw new ConnectionFailedException(ex);
}
catch (Exception ex)
{
//Don't know what happend...
}
return surveysList;
}
Code-Behind of UI:
private void bindGrid()
{
Survey survey = new Survey();
try
{
GridView1.DataSource = survey.getData();
GridView1.DataBind();
GridView1.Visible = true;
}
catch (ConnectionFailedException)
{
Label1.Text = "There was a problem accessing the database, please try again.";
}
}
However, I am still getting a red line under
ConnectionFailedException
in each tier and I don't know why, and it gave me the following error:
The type or namespace name 'ConnectionFailedException' could not be found (are you missing a using directive or an assembly reference?)TestWebsite\\App_Code\\DAL\\Survey.cs
How can I fix this thing? I don't want to create a class for each exception type that I am going to throw it like what I have done so far. Could you please provide me with a help and example if possible?
You haven't added Microsoft.Rfid.SpiSdk
assembly reference OR Dll
might be missed in the build
Namespace: Microsoft.SensorServices.Rfid.Dspi
Assembly: Microsoft.Rfid.SpiSdk (in microsoft.rfid.spisdk.dll)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.