J
John Hatpin
I'm new to C#, and I've been working on a casual project, learning as
I go, using SharpDevelop on WinXP, latest releases of everything.
Several times I've noticed that processing of a code block will
suddenly stop without any error, even with the debugger running, yet
the app continues.
For example, I have the following code in a class object's method,
which wasn't getting executed completely - I added in the messageboxes
to find out where processing was stopping:
[various statements ...]
this.List.Add(mGroupBox) ;
System.Windows.Forms.MessageBox.Show("adding control") ;
HostForm.Controls.Add(mGroupBox) ;
System.Windows.Forms.MessageBox.Show("control added") ;
mGroupBox.Text = CorrespondentName ;
[more statements ...]
Running that, I get the first messagebox but not the second, and
statements after the Controls.Add line don't get executed. Presumably,
there's something wrong with the Controls.Add line.
My question is not what's causing the code to fail - that would be a
separate question. My question is: is it normal for C# code to stop
executing like this, silently, with no indication that anything's
wrong apart from code unexpectedly not being executed?
It's certainly proving a pain to try to pin down errors like this, and
I've had this happen several times in different places, usually, it
seems, from unreferenced objects. The only sign I can see that
anything's wrong is the effect of that missed code later on, in
another part of the application.
I go, using SharpDevelop on WinXP, latest releases of everything.
Several times I've noticed that processing of a code block will
suddenly stop without any error, even with the debugger running, yet
the app continues.
For example, I have the following code in a class object's method,
which wasn't getting executed completely - I added in the messageboxes
to find out where processing was stopping:
[various statements ...]
this.List.Add(mGroupBox) ;
System.Windows.Forms.MessageBox.Show("adding control") ;
HostForm.Controls.Add(mGroupBox) ;
System.Windows.Forms.MessageBox.Show("control added") ;
mGroupBox.Text = CorrespondentName ;
[more statements ...]
Running that, I get the first messagebox but not the second, and
statements after the Controls.Add line don't get executed. Presumably,
there's something wrong with the Controls.Add line.
My question is not what's causing the code to fail - that would be a
separate question. My question is: is it normal for C# code to stop
executing like this, silently, with no indication that anything's
wrong apart from code unexpectedly not being executed?
It's certainly proving a pain to try to pin down errors like this, and
I've had this happen several times in different places, usually, it
seems, from unreferenced objects. The only sign I can see that
anything's wrong is the effect of that missed code later on, in
another part of the application.