473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Form Inhertiance Sometimes Not Working

I'm having some strange trouble with form inheritance.
FormA inherits FormB. The New method in FormA
passes an object to FormB via it's New method. The New
method of FormB then creates some other objects, several
of which reference the object just passed in.

This will be working just fine, then suddenly when I try to
open FormA in the IDE, I get "An error occurred while loading
the document. ..." Then
"Object reference not set to an instance of an object."

Even when it's in this state, I can run the project, and FormA shows
up just fine!

Sometimes I'm able to get things working again by referencing FormB
as a DLL instead of a project, but that doesn't always do the trick.

What am I doing wrong, and how can I get it to recover when this
happens?

Thanks for any tips!
---Selden McCabe


Nov 20 '05 #1
3 1245
This is actually a designer issue.

You call new, which instantiates certian objects I'm sure. The designer
(correct me if I'm wrong) calls the InitializeComponent Subroutine (from
New) in which case it creates all the objects that need to be done.

However, the designer only calls the non-overloaded version of the
constructor I believe, which could be why you are having problems... I ran
across the same thing, and had to do some stuff with IContainer...

I may be wrong, but it helped me.

-CJ
"Selden McCabe" <se*****@msn.com> wrote in message
news:el**************@TK2MSFTNGP11.phx.gbl...
I'm having some strange trouble with form inheritance.
FormA inherits FormB. The New method in FormA
passes an object to FormB via it's New method. The New
method of FormB then creates some other objects, several
of which reference the object just passed in.

This will be working just fine, then suddenly when I try to
open FormA in the IDE, I get "An error occurred while loading
the document. ..." Then
"Object reference not set to an instance of an object."

Even when it's in this state, I can run the project, and FormA shows
up just fine!

Sometimes I'm able to get things working again by referencing FormB
as a DLL instead of a project, but that doesn't always do the trick.

What am I doing wrong, and how can I get it to recover when this
happens?

Thanks for any tips!
---Selden McCabe

Nov 20 '05 #2
Thanks, to both of you for replying. Your answers, plus some other posts
here
helped me figure it out. Here's what it was, in case anyone else has the
same problem:

CJ Taylor was right! When you load an inherited form in the designer, it's
native
New method gets called, which then cannot pass an object to the base form.

The answer is to make sure both calls will work. In the normal case, New
from the
inherting form calls New on the inherited form, passing an object which, in
this case,
was used to derive other objects. So I added code in the native New method
of the
base form to instantiate the objects I needed. Problem solved!

Thanks again, you guys are great!
Nov 20 '05 #3
Rock on!

First the cubs win! And then I solve a pretty diffucult problem well!

Bling Bling ya'll!
"Selden McCabe" <se*****@msn.com> wrote in message
news:uh**************@TK2MSFTNGP11.phx.gbl...
Thanks, to both of you for replying. Your answers, plus some other posts
here
helped me figure it out. Here's what it was, in case anyone else has the
same problem:

CJ Taylor was right! When you load an inherited form in the designer, it's native
New method gets called, which then cannot pass an object to the base form.

The answer is to make sure both calls will work. In the normal case, New
from the
inherting form calls New on the inherited form, passing an object which, in this case,
was used to derive other objects. So I added code in the native New method of the
base form to instantiate the objects I needed. Problem solved!

Thanks again, you guys are great!

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jeremy | last post by:
I have a very large HTML form (with about 50 fields) that's being submitted to an ASP page via the "POST" method. I don't use "GET" because the data would probably exceed the limit allowed in the...
0
by: JF Turcotte | last post by:
Hi I'm unsuccessfully trying to print a form's image under VB.NET. To print under .NET is a real pain in the , I find it to be complex, lenghty, confusing, upsetting and ultimately not to be...
10
by: Sarah Smith | last post by:
Hello, I am a bit of a newbie to VB.NET, but not totally new. I took the plunge recently and decided (along with my colleagues), to try to convert/port a VB6 client/server app to .Net. (I'm...
8
by: bokke | last post by:
Can someone please help me with this? I have a form that I use on most of my sites - they all worked fine - then one day they stopped working. here is the code <? $name=$_POST;...
4
by: Michael | last post by:
Hi Everyone, I'm hoping someone out there can give me some guidance. I'm currenlty using VS2005 and the other day the Form Wizzard stopped working. What I mean, is that the wizzard no longer...
10
by: morangolds | last post by:
Hi, I've been having a problem with C++ Windows Forms apps not "ending" when you close the form window. I've searched about this problem all over the place and most searches have lead me to...
5
by: Drew | last post by:
I am having an issue with an app that I built, it seems that Request.Form doesn't want to work sometimes, and only sometimes. For instance, I got a call last week about an error, I had the user...
11
by: Twayne | last post by:
Hi, Newbie to PHP here, no C or other relevant background, so pretty niave w/r to the nuances etc. but I think this is pretty basic. XP Pro, SP2+, PHP 4.4.7, XAMPP Local Apache Server...
40
by: Jukka K. Korpela | last post by:
My basic style sheet has a distinctive background and border for forms, to make the structure clearer and to make it visually evident what belongs to a form. However, as people complained that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.