I'm having issues with a piece of code for a website in C# and when I debug it, it opens the site (localhost in Chrome. Every page works except the one I'm debugging, regardless of whether or not that's the page I'm debugging. Whenever I try to open it, it gives me an Object Reference error at the line I've marked below. This happens no matter which browser I use.
Protected void page_load (object sender, EventArgs e)
{
DateTime dteNow = SI.Getsource.DAL.Time.Now.Eastern();
If(!IsPostBack)
{
txtStartDate.SelectDate = dteNow.AddDays(-2)
txtEndDate.SelectedDate = dtenow.AddDays(1)
txtStartDate.Visible = False
txtEndDate.Visible = False
Shipping.DataTable.dt = SI.Getsource.DAL.EquipmentDB.getPrinter();
ddlPrinter.DataSource = dt.Result
ddlPrinter.DataTextField = dt.Result.Columns["Name"] //Error is here
ddlPrinter.DataValueField = dt.Result.Columns["PrinterID"]
ddlPrinter.DataBind();
Try
{
ddlPrinter.SelectedValue = System.Web.Configuration.WebConfigurationManager.AppSettings["DefaultPrinterID"]
}
Catch
}
}
I've tried running it in IE and Firefox. I also tried adding a try-catch for "Name" similar to the one for "Printer" but that didn't do anything. Any suggestions would be greatly appreciated, since this error prevents me from debugging the actual issue.
Edit: I'm using Visual Studio 2015. Also, this only happens when I run the page locally, ie. When debugging.
As it turns out, it was an issue with memory. Once I took care of that, it worked.