Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / February 2005

Tip: Looking for answers? Try searching our database.

Error in Form Constructor

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve W - 25 Jan 2005 20:32 GMT
We are hitting a problem that we can't explain and wondered if anyone has
seen this before or can suggest how we can stop it happening :

Form 'A' inherits from System.Windows.Forms.Form
Form 'B' inherits from Form 'A'.
Form C inherits from Form B.

Form B (the one in the middle) has a TextBox component on it.

The constructor of Form 'C' attempts to assign a string value to the 'Text'
property of the TextBox.  It does this after all form initialization has
taken place.

Occasionally (we haven't identified a definite pattern), when the code
assigning the 'Text' property of the TextBox executes, it falls over with an
exception 'Object variable not set to an instance of an object'.

The problem definitely lies with the assignment (i.e. does not lie with the
value being assigned).  We've also tried Me.TextBox.Text = value and
MyBase.TextBox.Text = value but still the same.  We've also tried assigning
values to different components (such as CheckBox.Checked = True) and the
same thing happens.  The component can be read; i.e. code like
MsgBox(TextBox.Text) works fine.

We thought we had solved the problem when discovering that if the component'
s properties have anything assigned to them at design time, then this
run-time issue would occur fairly frequently (but seemingly randomly).
Ensuring nothing is assigned at design time (i.e. the 'Text' property or
'Checked' property is not assigned at design time) seemed to halt the issue
occurring.  However, now it is occurring again and we can't fix it.

This does seem to be a form inheritance issue as I haven't seen it on any
forms that are just inherited from System.Windows.Forms.Form.

Thanks for any help,

Steve
"Jeffrey Tan[MSFT]" - 28 Jan 2005 08:38 GMT
Hi Steve,

Have you succeeded create out a sample project to reproduce this issue? Is
your problem resolved? Please feel free to tell me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Steve W - 30 Jan 2005 20:03 GMT
Jeffrey,

Some confusion our end.  One of my guys will be looking at it tomorrow.

Will keep you informed.

Thanks

Steve

> Hi Steve,
>
[quoted text clipped - 6 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
"Jeffrey Tan[MSFT]" - 01 Feb 2005 08:00 GMT
Ok, I will wait for your further feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.