Form Loading - Issue With Trapping for Errors

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I created a Windows application that is having an odd issue. The application
starts for a split second, but then closes. I cannot get any error messages
to display as to what causes the program to close. Listed below is my
Default_Load method. How would I be able to trap the error so I know what is
causing this form to not load as I do not get any information at this time.
We have it running on 4 different computers, but the one computer won't let
it run. We checked to make sure all the necessary drivers are installed, but
not sure what is conflicting.

private void Default_Load(object sender, EventArgs e)
{
try
{
this.tPCEXPXRFTSTTableAdapter.Fill(this.tPCEXPXRF.TPCEXPXRFTST);
dataGridView1.CellValidating += new
DataGridViewCellValidatingEventHandler
(dataGridView1_CellValidating);
this.dataGridView1.DataError += new DataGridViewDataErrorEventHandler
(dataGridView1_DataError);
}
catch (Exception ex)
{
System.Diagnostics.EventLog log = new
System.Diagnostics.EventLog();
log.Log = "System";
log.Source = "CE Item Lookup Table Editor";
log.WriteEntry(ex.ToString());
}
}
 
It is possible the code in your catch is failing. Might be a security issue,
where the user does not have rights to write to the event log.

Not sure why they would just shut down the app, though
 
Marina:

Thanks for the response, but I placed the try....catch code in to attempt to
trap the error that is stopping the form from loading.

In other words, the app failed before I added that code, so I don't think it
has to do with the actual try....catch.

Thanks
Andy
 
It may be a larger issue then, of not being able to find a required DLL, or
something that makes it impossible for the application to load at all.
 
Andy said:
I created a Windows application that is having an odd issue. The application
starts for a split second, but then closes. I cannot get any error messages

How are you starting your app? Do you have a main form and the startup
object is that form? Or are you starting from main? Can you show the
entry point of the application?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top