PDA

Click to See Complete Forum and Search --> : has this happened to anyone else


RichardAtherton
May 13th, 2002, 08:49 AM
well I don't knopw whether you can see it clearly, but this is the second time it has happened. I am desigining an application, which is fine and create a form, then go to make an inherited form and get the message error loading object reference not set to an instance of the object, alternatively is there any email support from Microsoft as I certainly couldn't find any.

ioslipstream
May 28th, 2002, 04:39 PM
Originally posted by RichardAtherton
well I don't knopw whether you can see it clearly, but this is the second time it has happened. I am desigining an application, which is fine and create a form, then go to make an inherited form and get the message error loading object reference not set to an instance of the object, alternatively is there any email support from Microsoft as I certainly couldn't find any.

I'm pretty sure this has to do with where in your code you instantiate your inherited form. You really would need to post a snippet(the relative snippets that is) of your code, to get a better answer than that.

hellswraith
May 28th, 2002, 05:21 PM
Sometimes the IDE will write over your instantiation of an object. This has to do with where you instantiate it as said before. Try instantiating your form right after this code:

'This call is required by the Windows Form Designer.
InitializeComponent()
'Put your instantiation code here.

RichardAtherton
Jun 1st, 2002, 02:53 AM
thanks for the replies, what I found in fact is that when you inherit fropm a form, as it loads the document (so that you can inherit it) it fires off the base load event and that was what was causing the problem - yes I also had problems because I had not instantiated that form by doing a run first.

Somewhere else I read a brief comment about setting designer mode on and off, however I'd had enough of all of that and simply moved the code out of the base load event and put it into a sub of it's own which I can then call to execute it.

That all seems to work fine now and I've had no problems wioth form inheritance since.

Maybe not the best or correct solution - but it worked!

DevGrp
Jun 1st, 2002, 09:55 AM
That has happened to me before also. I think it might be a bug in the IDE. This happens if I am working with more than 1 form and I have all of them open.

If I'm coding and I click on the design form, I get that error and then I have to reopen my project.