Cum Grano Salis

Can you be your own parent (And no, this is not a KUOW Weekday discussion)?

No you can't.

Or can you?

No, you can't.

Just ran into this bug in my code:

I was getting an annoying StackOverflow, but it was hard to figure out why because the debugger was not willing to show me the originating code - just the recurring call to the Parent property.

Once I used a "Hit Count" breakpoint and found the code where the call came from, it became much easier:

// Save/Download button.
m_openDownloadButton = new Button();
m_openDownloadButton.
Controls.Add(m_openDownloadButton);
m_openDownloadButton.Text = "Open/Download";
At some point I added a line containing "m_openDownloadButton." and did not complete whatever it was I wanted to write there. The code compiles fine, but tries to add a control as its own child, causing the SO.
Published Thursday, August 02, 2007 11:23 AM by Shahar
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required
Submit

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker