Click here to Skip to main content
15,912,457 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

This is c# windows applicaiton, and it calling a popup from parent form .
And there is a error in the frmPopup_Load, its catching the exception, but not throwing to the frmparnt form

Form parent
=======================================
C#
public frmParent()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                frmPopup frm = new frmPopup();
                frmPopup.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }



Popup Code
================================
C#
public frmPopup()
        {
            InitializeComponent();
        }

        private void frmPopup_Load(object sender, EventArgs e)
        {
            try
            {
                int i = 0;

                int j = 1 / i;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Posted
Updated 7-May-14 2:23am
v2

Check once by changing frmPopup_load access modifier private to public..
 
Share this answer
 
v2
Comments
clintoaug 7-May-14 8:36am    
Thanks for the reply
but its not working.
You could create a
C#
public event Action<string> ExceptionMessageEvent;</string>
in the popup form.
Set in the form that when you catch the exception:
C#
if (ExceptionMessageEvent != null)
    ExceptionMessageEvent(ex.Message);


In the parent form just before loading the popup the parent form can subscribe to that ExceptionMessageEvent in the popup form.
If that event is fired you can show the message.
 
Share this answer
 
Exceptions in the Load or Shown event of a Form get swallowed on 64bit systems (see e.g. https://connect.microsoft.com/VisualStudio/feedback/details/357311[^]).
Hence handle the exception inside the event handler, and if necessary, close the form.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900