PC Review


Reply
Thread Tools Rate Thread

VS.NET 2005 Designer - null reference exception

 
 
=?Utf-8?B?TWFoZXNoIE5pbWJhbGthcg==?=
Guest
Posts: n/a
 
      10th Aug 2007
I have a form "form1" that I can open in vs.net 2005 designer. Now I also
have "form2" which is derived from form1. I can not open this "form2" in
designer view which shows null reference exception on design view.

On call stack, it is showing that designer is trying to call form1.shown
method which has one reference which is not set yet.

How come I can open "form1" in design view but can not "form2"?

Any idea how to solve this problem?

--
Thanks,
Mahesh

 
Reply With Quote
 
 
 
 
Jason Allred
Guest
Posts: n/a
 
      10th Aug 2007
In Form2's constructor, do you call the Base (Form1) constructor? In VB
it's Mybase.New()

"Mahesh Nimbalkar" <(E-Mail Removed)> wrote in
message news:41DD418D-F42C-402F-8D6F-(E-Mail Removed)...
>I have a form "form1" that I can open in vs.net 2005 designer. Now I also
> have "form2" which is derived from form1. I can not open this "form2" in
> designer view which shows null reference exception on design view.
>
> On call stack, it is showing that designer is trying to call form1.shown
> method which has one reference which is not set yet.
>
> How come I can open "form1" in design view but can not "form2"?
>
> Any idea how to solve this problem?
>
> --
> Thanks,
> Mahesh
>



 
Reply With Quote
 
 
 
 
Jack Jackson
Guest
Posts: n/a
 
      10th Aug 2007
On Fri, 10 Aug 2007 14:58:08 -0700, Mahesh Nimbalkar
<(E-Mail Removed)> wrote:

>I have a form "form1" that I can open in vs.net 2005 designer. Now I also
>have "form2" which is derived from form1. I can not open this "form2" in
>designer view which shows null reference exception on design view.
>
>On call stack, it is showing that designer is trying to call form1.shown
>method which has one reference which is not set yet.
>
>How come I can open "form1" in design view but can not "form2"?
>
>Any idea how to solve this problem?


In order to show a form in the IDE, the IDE needs to instantiate the
parent class of the form, then it manually runs the
InitializeComponent method of the form to get the child objects
created. That apparently works fine for form1.

In order to show form2, the IDE needs to instantiate a form1 object,
and that apparently fails due to the reference which is not set. One
work-around is in form1 to check the DesignMode property and if True
avoid accessing the property that you know is not set. Or perhaps if
DesignMode is True you could set the reference to something safe that
would let the form instantiate.
 
Reply With Quote
 
=?Utf-8?B?TWFoZXNoIE5pbWJhbGthcg==?=
Guest
Posts: n/a
 
      11th Aug 2007
Thank you Jason. Your solution worked.
--
Thanks,
Mahesh



"Jason Allred" wrote:

> In Form2's constructor, do you call the Base (Form1) constructor? In VB
> it's Mybase.New()
>
> "Mahesh Nimbalkar" <(E-Mail Removed)> wrote in
> message news:41DD418D-F42C-402F-8D6F-(E-Mail Removed)...
> >I have a form "form1" that I can open in vs.net 2005 designer. Now I also
> > have "form2" which is derived from form1. I can not open this "form2" in
> > designer view which shows null reference exception on design view.
> >
> > On call stack, it is showing that designer is trying to call form1.shown
> > method which has one reference which is not set yet.
> >
> > How come I can open "form1" in design view but can not "form2"?
> >
> > Any idea how to solve this problem?
> >
> > --
> > Thanks,
> > Mahesh
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find out which ref-Variable is null, when exception is null reference Rolf Welskes Microsoft Dot NET Framework 2 26th Jan 2007 09:50 AM
any know issues in installing VB.NET 2005 Express, VS.NET 2005 Standard, SQL Server 2005 Express and SQL Server 2005 LeAnne Microsoft VB .NET 2 30th Dec 2005 12:27 PM
Security programs 2005 - , Firewall programs 2005 -, Antivirus programs 2005 -, APPDEV DOT NET SECURITY, Linux Security and Firewall programs 2005 -, CiscoWorks ( CW ) Security programs 2005 - , futa Microsoft Access Security 3 2nd Mar 2005 05:04 AM
Security programs 2005 - , Firewall programs 2005 -, Antivirus programs 2005 -, APPDEV DOT NET SECURITY, Linux Security and Firewall programs 2005 -, CiscoWorks ( CW ) Security programs 2005 - , futa Anti-Virus 0 25th Feb 2005 02:30 PM
McAfee 2005 All In One, McAfee AntiSpyware V1.0 2005, McAfee Personal Firewall Plus V6.0 2005, McAfee QuickClean V5.0 2005, McAfee SpamKiller V6.0 2005, McAfee VirusScan V9.0 2005, new !, other code_fu Anti-Virus 0 1st Oct 2004 11:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:15 PM.