Ctrl F5 exception and ignored on F5

Posted by user575219 on Stack Overflow See other posts from Stack Overflow or by user575219
Published on 2012-06-02T07:14:03Z Indexed on 2012/06/02 22:40 UTC
Read the original article Hit count: 248

Filed under:

I am getting this unhandled exception error shown: See screen shot.

enter image description here

I am getting this error only when I run with Ctrl+ F5 and not in F5(debug mode).Not sure if this is helpful,my computer is a windows 7- 64bit and running a 32 bit build

According to this discussion: How can I get WinForms to stop silently ignoring unhandled exceptions?,

Adding Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException) iwll cause Windows to ignore the error.

EDIT: frmPlant_Load Event

public partial class frmPlant : Form
    {
        DatabaseConnection _DbConnection = new DatabaseConnection();
        string conString = ConfigurationManager.ConnectionStrings["RVESTConnString"].ConnectionString;
        SQLQueries _SQlQueries = new SQLQueries();
        DataSet ds;
        SQLiteDataAdapter da;
       static DataTable gdt;
        int gSelectedPlant;
        string gSelectedPlantName = "";
        bool ignoreSelChg = false;
        bool DataDirty = false;
    public frmPlant()
        {
            InitializeComponent();        
        }
        public frmPlant(int sSelectedPlant)
        {
            InitializeComponent();           
        }
        private void frmPlant_Load(object sender, EventArgs e)
        {

            ds = FillData();
            gdt = ds.Tables[0];
            bindingSource1.DataSource = gdt;
            dataGridView1.DataSource = bindingSource1;
            gSelectedPlant = StaticClass.GlobalValue;
            dataGridView1.AutoGenerateColumns = true;
            dataGridView1.Columns["PlantId"].Visible = false;
            dataGridView1.Columns["NSSS_Design"].Width = 70;          
        }
        private DataSet FillData()
        {
            ignoreSelChg = true;
            SQLiteConnection con = new SQLiteConnection(conString);
            DataSet dPlant;
            try
            {
                con.Open();
                SQLiteCommand cmd = new SQLiteCommand("select * from Plant", con);
                da = new SQLiteDataAdapter("select * from Plant", con);
                dPlant = new DataSet();
                da.Fill(dPlant, "plant"); 

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }
            return dPlant;
        }

I should also add another concern: When I say continue here in the dialog, it works fine but leaves a background process running. I have to manually go and kill it in the task manager

Question: Suppose I add this line in the Program.cs, will it ignore ANY- even genuine errors which need to be fixed?

More Code: This dialog pops up on button click on the second screen- Initial Setup screen . The first being a splash screen. Initial setup takes me to the Plant form

Here's the code for the initial setup screen

     public partial class frmInitialSetUp : Form
    {
        public frmInitialSetUp()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            Program.fPlant = new frmPlant();
            Program.fPlant.Show();
            this.Hide();
        }

        private void frmInitialSetUp_Load(object sender, EventArgs e)
        {
            Program.LoadAllForms();   
        }
    }
}
Program.cs
      static public void LoadAllForms()
        {
            try
            {
                Program.fInitialSetUp = new frmInitialSetUp();
                Program.fPlant = new frmPlant();
                Program.frm*** = new frm***();
                Program.frm*** = new frm***();
                Program.frm*** = new frm***();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

On button click on the

© Stack Overflow or respective owner

Related posts about c#