The problematic method, PopulateTransactionListBoxWithWorkTables(), gets called from the main form's Load event:
private void frmMain_Load(object sender, EventArgs e)
{
ExceptionLoggingService.Instance.WriteLog("Reached frmMain.frmMain_Load");
ServicePointManager.CertificatePolicy = new TrustAllCertificatesPolicy();
PopulateTransactionListBoxWithWorkTables();
}
Somewhere in that method, it fails with an NRE; I've sprinkled in a bunch of log msgs to see just where it's failing:
private void PopulateTransactionListBoxWithWorkTables()
{
ExceptionLoggingService.Instance.WriteLog("Reached
frmMain.PopulateTransactionListBoxWithWorkTable");
menuItemSEND_Deliveries.Enabled = false;
menuItemSEND_Inventories.Enabled = false;
try
{
listBoxWork.Items.Clear();
ExceptionLoggingService.Instance.WriteLog("Reached
frmMain.PopulateTransactionListBoxWithWorkTable#2");
if (!hhsdbutils.TableExists("WorkTable"))
{
ExceptionLoggingService.Instance.WriteLog("Reached
frmMain.PopulateTransactionListBoxWithWorkTable#3a");
String msg = HHSConsts.NO_CURRENT_WORK;
listBoxWork.Items.Add(msg);
}
else
{
ExceptionLoggingService.Instance.WriteLog("Reached
frmMain.PopulateTransactionListBoxWithWorkTable#3b");
List<String> workTables = hhsdbutils.GetWorkTableNames();
menuItemTopSend.Enabled = workTables.Count > 0;
foreach (String wt in workTables)
{
// TODO: This will cause enabled to be set to true each time a corresponding
item is found, which should be improved
if (wt.IndexOf("DSD") == 0)
{
menuItemSEND_Deliveries.Enabled = true;
}
if (wt.IndexOf("INV") == 0)
{
menuItemSEND_Inventories.Enabled = true;
}
listBoxWork.Items.Add(wt);
}
ExceptionLoggingService.Instance.WriteLog("Reached
frmMain.PopulateTransactionListBoxWithWorkTable#4");
if (listBoxWork.Items.Count > 0)
{
listBoxWork.SelectedIndex = 0;
}
}
}
catch (Exception ex)
{
String msgInnerExAndStackTrace = String.Format(
"{0}; Inner Ex: {1}; Stack Trace: {2}", ex.Message, ex.InnerException, ex.StackTrace);
MessageBox.Show(String.Format("Exception in
PopulateTransactionListBoxWithWorkTable(): {0}", msgInnerExAndStackTrace));
ExceptionLoggingService.Instance.WriteLog(String.Format("From
frmMain.PopulateTransactionListBoxWithWorkTable: {0}", msgInnerExAndStackTrace));
}
} // populateListBoxWithWorkTableData
The log file shows that it gets to #2 in PopulateTransactionListBoxWithWorkTables(), but not to #3 (a or b) there:
Message: Reached frmMain.frmMain_Load
Date: 4/3/2009 2:13:28 AM
Message: Reached frmMain.PopulateTransactionListBoxWithWorkTable
Date: 4/3/2009 2:13:28 AM
Message: Reached frmMain.PopulateTransactionListBoxWithWorkTable#2
Date: 4/3/2009 2:13:31 AM
Message: Reached frmMain.frmMain_Activated
Date: 4/3/2009 2:13:31 AM
Message: From frmMain.PopulateTransactionListBoxWithWorkTable: NullReferenceException; Inner Ex: ; Stack Trace: at HHS.frmMain.PopulateTransactionListBoxWithWorkTables()
at HHS.frmMain.frmMain_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form._SetVisibleNotify(Boolean fVis)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.Run(Form fm)
at HHS.Program.Main()
... so it's dying when calling TableExists(); here is that method:
bool IHHSDBUtils.TableExists(string tableName)
{
ExceptionLoggingService.Instance.WriteLog(String.Format("Reached
SQliteHHSDBUtils.TableExists ({0})", tableName));
// If the database file itself does not exist, there's no way the table could exist, so cut
to the chase:
if (!File.Exists(expectedSQLiteLocAndName)) return false;
. . .
...the log msg at the start of TableExistsis not getting logged, so it seems to blow up as soon as it reaches it...why would that be the case?!?
Note: frmMain_Activated() has no code in it other than the log string write.