Unexplained form crash

Ggilmann

Member
Joined
Feb 12, 2011
Messages
17
Location
Canada
Programming Experience
3-5
Hello,

I'm panicking right now. I was developping my app, everything was going smoothly. Then all of a sudden, my app started crashing right after I call form.show. Furthermore, this call is situated in a Try block, and the error is not caught!

One of my guess is that it's related to the controls in my form, but I have no clue where to start looknig for the error.

I really need help on this.

Thanks,

Ggilmann
 
Ok, I believe I found the problem using a "brute force" approach if you will. I deleted all my controls and started adding all of the one by one, reassociating all the events and such.

It seems the problem was with a label control I had on my form. This label contained only blank spaces in order to produce some sort of line separating two parts of my form. Apparently VB Net doesn't like that at all.

Si if anybody sees this and has a suggestion of something that would work as a line separator, it would be appreciated.

Thanks,

Ggilmann
 
VB.NET has no issue with Labels containing only spaces. Assuming no actual corruption, the issue would have been with your code and how you were using it.

A "crash" in a .NET application is an unhandled exception. If an exception goes unhandled in the debugger, the Exception Assistant is displayed and it provides you with lots of diagnostic information. Did you read that dialogue? Did you click the "View Details" link? It would have given you an error message and a call stack showing you where the original exception was thrown.

The most likely general cause is that one of the properties you have set in the designer causes an event to be raised during form initialisation and, in the handler for that event, you are assuming some condition that is not true at that time. For example, if you have set an initial value for the Text property of a TextBox, the designer-generated code will set the Text property during initialisation and that will raise a TextChanged event. If you're handling that event and assuming that some other object exists that hasn't been created yet, you'll get a NullReferenceException thrown.
 
Like I said, I cannot explain it to myself. I had simply dragged a label from the toolbox to my form, then I set it's property. I believe I had changed the font to size 1, changed the background color, then changed the text to multiple spaces. I also was running my app from a third party application.

My form.show call was in a try block, my form new was also in a try block. The crash was happening between those calls. No code was referring to my label and I had not changed the designer file!

I actually managed to reproduce it too. When I was adding my controls one by one, as soon as i added that label again, it crashed again.
 
Well, I can't reproduce it anymore... I'm pretty sure you're right, as in there was a problem with the designer file. However, like i said, I never changed it manually.

This is intriguing
 
Back
Top