Ok so I have this weird problem, and I’ve searched Google many times for an answer but to no avail… Anyways I have this problem where I can’t seem to get my program(s) to show me error messages when I want. This has happened on many occasions and eventually figure out that its a variable that’s null, but for some reason no error was thrown?
Here’s an example of one I just had.
Person clicks a button to show a new form called debug.
Debug debug = new Debug();
debug.Show(this);
And this was in my debug form.
public new void Show(IWin32Window owner)
{
base.Show(owner);
Parent.Move += new EventHandler(delegate(object sender, EventArgs e)
{
Location = new Point(Parent.Location.X + Parent.Width, Parent.Location.Y);
});
}
Long story short, the code didn’t work because Parent was null but it never even hinted that was the problem.
I’m sure there some explanation but I have yet to find one in my Google searches…
You can also try the following in Visual Studio:
It will now cause the debugger to break whenever a NullReferenceException is thrown.
I would guess that either your Application is wrapped in a try{} catch{} or, somewhere at the base of the callstack that results in debug.Show() being called, the code is wrapped in a try{} catch{}