Rick2047
Rick2047

Reputation: 1595

C# says this.Controls is null, why?

Earlier my code was running nicely.. then I edited some .. did not touch the designer code.

alt text http://img718.imageshack.us/img718/3759/errorstack.jpg

Why this error is being shown?

Upvotes: 0

Views: 1090

Answers (3)

Rasshme
Rasshme

Reputation: 1641

Looks like, at this point in code label1 is not yet initialized. Whic event handler are you coding this in ? Make sure controls are initialized before using them. Make sure you are using the controls after InitComplete event.

Upvotes: 0

stuartd
stuartd

Reputation: 73243

If this is Windows Forms - did you remove the InitializeComponent() line from the form's constructor?

Upvotes: 1

das_weezul
das_weezul

Reputation: 6142

Maybe its the label is Null and that's causing the trouble. I'm not that experienced with C# but it could be the case that Controls doesn't except a Null-Pointer.

Upvotes: 0

Related Questions