473,418 Members | 2,023 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,418 software developers and data experts.

Mysterious Error: Object reference not set to an instance of an object

Max
Hi There!

I'm having a mysterious error right after I login using Forms Authentication
in my ASP.NET app. Below is the error...

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

The exception throws at the code that tries to set a property (String data
type) at my Menu user control.

When I refresh the page, the page render successfully without any
exceptions! Why?? My conclusion is that there are no exceptions in the first
place. I can't think why ASP.NET throws the exception when I access the page
for first time but not the second time! This exception is totally
unpredictable and unreasonable!

Plz help!!!

My SYS specs are...
- ASP.NET 1.1
- Windows XP (This error also occurs on Windows 2000 and Windows Server 2003
as well)

Thank you all in advance.

Max
Nov 19 '05 #1
13 2404
Probably not going to help, but I had a similar issue when trying to access
public properties of a web user control (I think thats what it's called... an
ASCX control).

For some reason the control wasn't be instantiated correctly, or posted back
to correctly.

I created a second page exactly in the same manner as the first, copied the
code and it worked. I deleted the first page, renamed the 2nd to the right
name and moved on.

If you make a brand new page w/ nothing but your control on it does it fail
as well?
"Max" wrote:
Hi There!

I'm having a mysterious error right after I login using Forms Authentication
in my ASP.NET app. Below is the error...

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

The exception throws at the code that tries to set a property (String data
type) at my Menu user control.

When I refresh the page, the page render successfully without any
exceptions! Why?? My conclusion is that there are no exceptions in the first
place. I can't think why ASP.NET throws the exception when I access the page
for first time but not the second time! This exception is totally
unpredictable and unreasonable!

Plz help!!!

My SYS specs are...
- ASP.NET 1.1
- Windows XP (This error also occurs on Windows 2000 and Windows Server 2003
as well)

Thank you all in advance.

Max

Nov 19 '05 #2
The NullReferenceException indicates that you are referencing an object in a
line of code, and that the object is null, or Nothing. It is not
instantiated. If you post the line of code which throws the exception, I can
tell you all of the object references in the line of code which may or may
not be null. After that, it will be up to you to determine which, and why.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Max" <ze**@maxdot.com.com> wrote in message
news:Ox****************@TK2MSFTNGP15.phx.gbl...
Hi There!

I'm having a mysterious error right after I login using Forms
Authentication in my ASP.NET app. Below is the error...

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

The exception throws at the code that tries to set a property (String data
type) at my Menu user control.

When I refresh the page, the page render successfully without any
exceptions! Why?? My conclusion is that there are no exceptions in the
first place. I can't think why ASP.NET throws the exception when I access
the page for first time but not the second time! This exception is totally
unpredictable and unreasonable!

Plz help!!!

My SYS specs are...
- ASP.NET 1.1
- Windows XP (This error also occurs on Windows 2000 and Windows Server
2003 as well)

Thank you all in advance.

Max

Nov 19 '05 #3
Inside the Page_Load function on the page i believe there is a
if(!Page.IsPostBack)
that is loading the Object. Look there.

Kevin Spencer wrote:
The NullReferenceException indicates that you are referencing an object in a line of code, and that the object is null, or Nothing. It is not
instantiated. If you post the line of code which throws the exception, I can tell you all of the object references in the line of code which may or may not be null. After that, it will be up to you to determine which, and why.
--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.

"Max" <ze**@maxdot.com.com> wrote in message
news:Ox****************@TK2MSFTNGP15.phx.gbl...
Hi There!

I'm having a mysterious error right after I login using Forms
Authentication in my ASP.NET app. Below is the error...

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

The exception throws at the code that tries to set a property (String data type) at my Menu user control.

When I refresh the page, the page render successfully without any
exceptions! Why?? My conclusion is that there are no exceptions in the first place. I can't think why ASP.NET throws the exception when I access the page for first time but not the second time! This exception is totally unpredictable and unreasonable!

Plz help!!!

My SYS specs are...
- ASP.NET 1.1
- Windows XP (This error also occurs on Windows 2000 and Windows Server 2003 as well)

Thank you all in advance.

Max


Nov 19 '05 #4
Are you the same person who asked the original question? If so, you need to
post the offending line of code. If not, what the heck are you talking
about?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Navajo Boy" <na***********@rocketmail.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
Inside the Page_Load function on the page i believe there is a
if(!Page.IsPostBack)
that is loading the Object. Look there.

Kevin Spencer wrote:
The NullReferenceException indicates that you are referencing an

object in a
line of code, and that the object is null, or Nothing. It is not
instantiated. If you post the line of code which throws the

exception, I can
tell you all of the object references in the line of code which may

or may
not be null. After that, it will be up to you to determine which, and

why.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.

"Max" <ze**@maxdot.com.com> wrote in message
news:Ox****************@TK2MSFTNGP15.phx.gbl...
> Hi There!
>
> I'm having a mysterious error right after I login using Forms
> Authentication in my ASP.NET app. Below is the error...
>
> Exception Details: System.NullReferenceException: Object reference not set > to an instance of an object.
>
> The exception throws at the code that tries to set a property (String data > type) at my Menu user control.
>
> When I refresh the page, the page render successfully without any
> exceptions! Why?? My conclusion is that there are no exceptions in the > first place. I can't think why ASP.NET throws the exception when I access > the page for first time but not the second time! This exception is totally > unpredictable and unreasonable!
>
> Plz help!!!
>
> My SYS specs are...
> - ASP.NET 1.1
> - Windows XP (This error also occurs on Windows 2000 and Windows Server > 2003 as well)
>
> Thank you all in advance.
>
> Max
>

Nov 19 '05 #5
I think Navajo is right... the problem lies in 'if(!Page.IsPostBack)' of
Page_Load().
...... whenever any control does a postback it goes through the
Page_Load() again. So the code that we donot want to run on every postback we
give in 'if(!Page.IsPostBack) {...}'. The code inside this loop only executes
when the page is loaded for the first time or an equivalent situation when we
refresh the page. I think thts where your problem lies Max. I think you are
initialising the menu control inside this if loop and somehow somewhere your
menu control loses its value, b4 coming back to page_load() on some postback.
And when it comes there its does not initialise the menu control as this code
is inside the if loop and it goes inside the if loop only when its not a
postback.
If you are initialising menu control in Page_Load() inside the
'if(!Page.IsPostBack)' try doing it outside this loop.
I am not very sure of your problem but if what I think your problem is is
correct then I guess this should work.
"Kevin Spencer" wrote:
Are you the same person who asked the original question? If so, you need to
post the offending line of code. If not, what the heck are you talking
about?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Navajo Boy" <na***********@rocketmail.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
Inside the Page_Load function on the page i believe there is a
if(!Page.IsPostBack)
that is loading the Object. Look there.

Kevin Spencer wrote:
The NullReferenceException indicates that you are referencing an

object in a
line of code, and that the object is null, or Nothing. It is not
instantiated. If you post the line of code which throws the

exception, I can
tell you all of the object references in the line of code which may

or may
not be null. After that, it will be up to you to determine which, and

why.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.

"Max" <ze**@maxdot.com.com> wrote in message
news:Ox****************@TK2MSFTNGP15.phx.gbl...
> Hi There!
>
> I'm having a mysterious error right after I login using Forms
> Authentication in my ASP.NET app. Below is the error...
>
> Exception Details: System.NullReferenceException: Object reference

not set
> to an instance of an object.
>
> The exception throws at the code that tries to set a property

(String data
> type) at my Menu user control.
>
> When I refresh the page, the page render successfully without any
> exceptions! Why?? My conclusion is that there are no exceptions in

the
> first place. I can't think why ASP.NET throws the exception when I

access
> the page for first time but not the second time! This exception is

totally
> unpredictable and unreasonable!
>
> Plz help!!!
>
> My SYS specs are...
> - ASP.NET 1.1
> - Windows XP (This error also occurs on Windows 2000 and Windows

Server
> 2003 as well)
>
> Thank you all in advance.
>
> Max
>


Nov 19 '05 #6
but yeah one should be really cautious putting some code outside
'if(!Page.IsPostBack)' as it may have negetive impact on performance.
"Yatendra Khandelwal" wrote:
I think Navajo is right... the problem lies in 'if(!Page.IsPostBack)' of
Page_Load().
...... whenever any control does a postback it goes through the
Page_Load() again. So the code that we donot want to run on every postback we
give in 'if(!Page.IsPostBack) {...}'. The code inside this loop only executes
when the page is loaded for the first time or an equivalent situation when we
refresh the page. I think thts where your problem lies Max. I think you are
initialising the menu control inside this if loop and somehow somewhere your
menu control loses its value, b4 coming back to page_load() on some postback.
And when it comes there its does not initialise the menu control as this code
is inside the if loop and it goes inside the if loop only when its not a
postback.
If you are initialising menu control in Page_Load() inside the
'if(!Page.IsPostBack)' try doing it outside this loop.
I am not very sure of your problem but if what I think your problem is is
correct then I guess this should work.
"Kevin Spencer" wrote:
Are you the same person who asked the original question? If so, you need to
post the offending line of code. If not, what the heck are you talking
about?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Navajo Boy" <na***********@rocketmail.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
Inside the Page_Load function on the page i believe there is a
if(!Page.IsPostBack)
that is loading the Object. Look there.

Kevin Spencer wrote:
> The NullReferenceException indicates that you are referencing an
object in a
> line of code, and that the object is null, or Nothing. It is not
> instantiated. If you post the line of code which throws the
exception, I can
> tell you all of the object references in the line of code which may
or may
> not be null. After that, it will be up to you to determine which, and
why.
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> Neither a follower nor a lender be.
>
> "Max" <ze**@maxdot.com.com> wrote in message
> news:Ox****************@TK2MSFTNGP15.phx.gbl...
> > Hi There!
> >
> > I'm having a mysterious error right after I login using Forms
> > Authentication in my ASP.NET app. Below is the error...
> >
> > Exception Details: System.NullReferenceException: Object reference
not set
> > to an instance of an object.
> >
> > The exception throws at the code that tries to set a property
(String data
> > type) at my Menu user control.
> >
> > When I refresh the page, the page render successfully without any
> > exceptions! Why?? My conclusion is that there are no exceptions in
the
> > first place. I can't think why ASP.NET throws the exception when I
access
> > the page for first time but not the second time! This exception is
totally
> > unpredictable and unreasonable!
> >
> > Plz help!!!
> >
> > My SYS specs are...
> > - ASP.NET 1.1
> > - Windows XP (This error also occurs on Windows 2000 and Windows
Server
> > 2003 as well)
> >
> > Thank you all in advance.
> >
> > Max
> >


Nov 19 '05 #7
Max
I did that and the same exception thrown when I refresh the page repadily.

max

"cmay" <cm**@discussions.microsoft.com> wrote in message
news:B5**********************************@microsof t.com...
Probably not going to help, but I had a similar issue when trying to
access
public properties of a web user control (I think thats what it's called...
an
ASCX control).

For some reason the control wasn't be instantiated correctly, or posted
back
to correctly.

I created a second page exactly in the same manner as the first, copied
the
code and it worked. I deleted the first page, renamed the 2nd to the
right
name and moved on.

If you make a brand new page w/ nothing but your control on it does it
fail
as well?
"Max" wrote:
Hi There!

I'm having a mysterious error right after I login using Forms
Authentication
in my ASP.NET app. Below is the error...

Exception Details: System.NullReferenceException: Object reference not
set
to an instance of an object.

The exception throws at the code that tries to set a property (String
data
type) at my Menu user control.

When I refresh the page, the page render successfully without any
exceptions! Why?? My conclusion is that there are no exceptions in the
first
place. I can't think why ASP.NET throws the exception when I access the
page
for first time but not the second time! This exception is totally
unpredictable and unreasonable!

Plz help!!!

My SYS specs are...
- ASP.NET 1.1
- Windows XP (This error also occurs on Windows 2000 and Windows Server
2003
as well)

Thank you all in advance.

Max

Nov 19 '05 #8
Max
Hi Kevin,

Thanks for the reply.

What I have is an ASPX page, with one Header.ascx control which accepts
comma delimited menu items (such as Menu1,Menu2,Menu3). For testing
purposes, I've created a blank ASPX page with only header ASCX control on it
and on Page_Load, I set the menu items "Menu1,Menu2,Menu3".

I refresh the page rapidly. Every two or three refresh, I get the "Object
reference not set to an instance of an object" at the point where I tried to
assign the menu item values. So I commented out that line and I tried to
access MenuBarColor property of the header control. The SAME error
produces!!! So I concluded that my Header control is not instantiated for
some reason when I do rapid refresh.

Is this normal for ASP.NET to produce this error when rapidly refreshed or
what I'm doing wrong?

max

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:er**************@TK2MSFTNGP12.phx.gbl...
The NullReferenceException indicates that you are referencing an object in
a line of code, and that the object is null, or Nothing. It is not
instantiated. If you post the line of code which throws the exception, I
can tell you all of the object references in the line of code which may or
may not be null. After that, it will be up to you to determine which, and
why.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.

"Max" <ze**@maxdot.com.com> wrote in message
news:Ox****************@TK2MSFTNGP15.phx.gbl...
Hi There!

I'm having a mysterious error right after I login using Forms
Authentication in my ASP.NET app. Below is the error...

Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

The exception throws at the code that tries to set a property (String
data type) at my Menu user control.

When I refresh the page, the page render successfully without any
exceptions! Why?? My conclusion is that there are no exceptions in the
first place. I can't think why ASP.NET throws the exception when I access
the page for first time but not the second time! This exception is
totally unpredictable and unreasonable!

Plz help!!!

My SYS specs are...
- ASP.NET 1.1
- Windows XP (This error also occurs on Windows 2000 and Windows Server
2003 as well)

Thank you all in advance.

Max


Nov 19 '05 #9
Max
Hi Yatendra,

My page does not utilize the Page.IsPostBack.

max

"Yatendra Khandelwal" <ya*****************@ishisystems.com.(donotspam) >
wrote in message news:14**********************************@microsof t.com...
I think Navajo is right... the problem lies in 'if(!Page.IsPostBack)' of
Page_Load().
...... whenever any control does a postback it goes through the
Page_Load() again. So the code that we donot want to run on every postback
we
give in 'if(!Page.IsPostBack) {...}'. The code inside this loop only
executes
when the page is loaded for the first time or an equivalent situation when
we
refresh the page. I think thts where your problem lies Max. I think you
are
initialising the menu control inside this if loop and somehow somewhere
your
menu control loses its value, b4 coming back to page_load() on some
postback.
And when it comes there its does not initialise the menu control as this
code
is inside the if loop and it goes inside the if loop only when its not a
postback.
If you are initialising menu control in Page_Load() inside the
'if(!Page.IsPostBack)' try doing it outside this loop.
I am not very sure of your problem but if what I think your problem is is
correct then I guess this should work.
"Kevin Spencer" wrote:
Are you the same person who asked the original question? If so, you need
to
post the offending line of code. If not, what the heck are you talking
about?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Navajo Boy" <na***********@rocketmail.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
> Inside the Page_Load function on the page i believe there is a
> if(!Page.IsPostBack)
> that is loading the Object. Look there.
>
>
>
> Kevin Spencer wrote:
>> The NullReferenceException indicates that you are referencing an
> object in a
>> line of code, and that the object is null, or Nothing. It is not
>> instantiated. If you post the line of code which throws the
> exception, I can
>> tell you all of the object references in the line of code which may
> or may
>> not be null. After that, it will be up to you to determine which, and
> why.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> .Net Developer
>> Neither a follower nor a lender be.
>>
>> "Max" <ze**@maxdot.com.com> wrote in message
>> news:Ox****************@TK2MSFTNGP15.phx.gbl...
>> > Hi There!
>> >
>> > I'm having a mysterious error right after I login using Forms
>> > Authentication in my ASP.NET app. Below is the error...
>> >
>> > Exception Details: System.NullReferenceException: Object reference
> not set
>> > to an instance of an object.
>> >
>> > The exception throws at the code that tries to set a property
> (String data
>> > type) at my Menu user control.
>> >
>> > When I refresh the page, the page render successfully without any
>> > exceptions! Why?? My conclusion is that there are no exceptions in
> the
>> > first place. I can't think why ASP.NET throws the exception when I
> access
>> > the page for first time but not the second time! This exception is
> totally
>> > unpredictable and unreasonable!
>> >
>> > Plz help!!!
>> >
>> > My SYS specs are...
>> > - ASP.NET 1.1
>> > - Windows XP (This error also occurs on Windows 2000 and Windows
> Server
>> > 2003 as well)
>> >
>> > Thank you all in advance.
>> >
>> > Max
>> >
>


Nov 19 '05 #10
What on earth makes you think that that particular line of code is in every
ASP.Net Page class?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Yatendra Khandelwal" <ya*****************@ishisystems.com.(donotspam) >
wrote in message news:14**********************************@microsof t.com...
I think Navajo is right... the problem lies in 'if(!Page.IsPostBack)' of
Page_Load().
...... whenever any control does a postback it goes through the
Page_Load() again. So the code that we donot want to run on every postback
we
give in 'if(!Page.IsPostBack) {...}'. The code inside this loop only
executes
when the page is loaded for the first time or an equivalent situation when
we
refresh the page. I think thts where your problem lies Max. I think you
are
initialising the menu control inside this if loop and somehow somewhere
your
menu control loses its value, b4 coming back to page_load() on some
postback.
And when it comes there its does not initialise the menu control as this
code
is inside the if loop and it goes inside the if loop only when its not a
postback.
If you are initialising menu control in Page_Load() inside the
'if(!Page.IsPostBack)' try doing it outside this loop.
I am not very sure of your problem but if what I think your problem is is
correct then I guess this should work.
"Kevin Spencer" wrote:
Are you the same person who asked the original question? If so, you need
to
post the offending line of code. If not, what the heck are you talking
about?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Navajo Boy" <na***********@rocketmail.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
> Inside the Page_Load function on the page i believe there is a
> if(!Page.IsPostBack)
> that is loading the Object. Look there.
>
>
>
> Kevin Spencer wrote:
>> The NullReferenceException indicates that you are referencing an
> object in a
>> line of code, and that the object is null, or Nothing. It is not
>> instantiated. If you post the line of code which throws the
> exception, I can
>> tell you all of the object references in the line of code which may
> or may
>> not be null. After that, it will be up to you to determine which, and
> why.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> .Net Developer
>> Neither a follower nor a lender be.
>>
>> "Max" <ze**@maxdot.com.com> wrote in message
>> news:Ox****************@TK2MSFTNGP15.phx.gbl...
>> > Hi There!
>> >
>> > I'm having a mysterious error right after I login using Forms
>> > Authentication in my ASP.NET app. Below is the error...
>> >
>> > Exception Details: System.NullReferenceException: Object reference
> not set
>> > to an instance of an object.
>> >
>> > The exception throws at the code that tries to set a property
> (String data
>> > type) at my Menu user control.
>> >
>> > When I refresh the page, the page render successfully without any
>> > exceptions! Why?? My conclusion is that there are no exceptions in
> the
>> > first place. I can't think why ASP.NET throws the exception when I
> access
>> > the page for first time but not the second time! This exception is
> totally
>> > unpredictable and unreasonable!
>> >
>> > Plz help!!!
>> >
>> > My SYS specs are...
>> > - ASP.NET 1.1
>> > - Windows XP (This error also occurs on Windows 2000 and Windows
> Server
>> > 2003 as well)
>> >
>> > Thank you all in advance.
>> >
>> > Max
>> >
>


Nov 19 '05 #11
So, Max, getting back to my question...

Would you please post the offending line of code?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Max" <ze**@maxdot.com.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Yatendra,

My page does not utilize the Page.IsPostBack.

max

"Yatendra Khandelwal" <ya*****************@ishisystems.com.(donotspam) >
wrote in message
news:14**********************************@microsof t.com...
I think Navajo is right... the problem lies in 'if(!Page.IsPostBack)' of
Page_Load().
...... whenever any control does a postback it goes through the
Page_Load() again. So the code that we donot want to run on every
postback we
give in 'if(!Page.IsPostBack) {...}'. The code inside this loop only
executes
when the page is loaded for the first time or an equivalent situation
when we
refresh the page. I think thts where your problem lies Max. I think you
are
initialising the menu control inside this if loop and somehow somewhere
your
menu control loses its value, b4 coming back to page_load() on some
postback.
And when it comes there its does not initialise the menu control as this
code
is inside the if loop and it goes inside the if loop only when its not a
postback.
If you are initialising menu control in Page_Load() inside the
'if(!Page.IsPostBack)' try doing it outside this loop.
I am not very sure of your problem but if what I think your problem is is
correct then I guess this should work.
"Kevin Spencer" wrote:
Are you the same person who asked the original question? If so, you need
to
post the offending line of code. If not, what the heck are you talking
about?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Navajo Boy" <na***********@rocketmail.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
> Inside the Page_Load function on the page i believe there is a
> if(!Page.IsPostBack)
> that is loading the Object. Look there.
>
>
>
> Kevin Spencer wrote:
>> The NullReferenceException indicates that you are referencing an
> object in a
>> line of code, and that the object is null, or Nothing. It is not
>> instantiated. If you post the line of code which throws the
> exception, I can
>> tell you all of the object references in the line of code which may
> or may
>> not be null. After that, it will be up to you to determine which, and
> why.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> .Net Developer
>> Neither a follower nor a lender be.
>>
>> "Max" <ze**@maxdot.com.com> wrote in message
>> news:Ox****************@TK2MSFTNGP15.phx.gbl...
>> > Hi There!
>> >
>> > I'm having a mysterious error right after I login using Forms
>> > Authentication in my ASP.NET app. Below is the error...
>> >
>> > Exception Details: System.NullReferenceException: Object reference
> not set
>> > to an instance of an object.
>> >
>> > The exception throws at the code that tries to set a property
> (String data
>> > type) at my Menu user control.
>> >
>> > When I refresh the page, the page render successfully without any
>> > exceptions! Why?? My conclusion is that there are no exceptions in
> the
>> > first place. I can't think why ASP.NET throws the exception when I
> access
>> > the page for first time but not the second time! This exception is
> totally
>> > unpredictable and unreasonable!
>> >
>> > Plz help!!!
>> >
>> > My SYS specs are...
>> > - ASP.NET 1.1
>> > - Windows XP (This error also occurs on Windows 2000 and Windows
> Server
>> > 2003 as well)
>> >
>> > Thank you all in advance.
>> >
>> > Max
>> >
>


Nov 19 '05 #12
It would help if you post the offending line of code. No, it is not normal
for you to get that exception, unless there is a bug in your code.

BTW, tip: Stick to one thread. Don't start new ones. Unlike Hansel and
Gretel, you're posts don't leave bread crumbs!

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Max" <ze**@maxdot.com.com> wrote in message
news:OR**************@tk2msftngp13.phx.gbl...
Hi Kevin,

Thanks for the reply.

What I have is an ASPX page, with one Header.ascx control which accepts
comma delimited menu items (such as Menu1,Menu2,Menu3). For testing
purposes, I've created a blank ASPX page with only header ASCX control on
it and on Page_Load, I set the menu items "Menu1,Menu2,Menu3".

I refresh the page rapidly. Every two or three refresh, I get the "Object
reference not set to an instance of an object" at the point where I tried
to assign the menu item values. So I commented out that line and I tried
to access MenuBarColor property of the header control. The SAME error
produces!!! So I concluded that my Header control is not instantiated for
some reason when I do rapid refresh.

Is this normal for ASP.NET to produce this error when rapidly refreshed or
what I'm doing wrong?

max

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:er**************@TK2MSFTNGP12.phx.gbl...
The NullReferenceException indicates that you are referencing an object
in a line of code, and that the object is null, or Nothing. It is not
instantiated. If you post the line of code which throws the exception, I
can tell you all of the object references in the line of code which may
or may not be null. After that, it will be up to you to determine which,
and why.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.

"Max" <ze**@maxdot.com.com> wrote in message
news:Ox****************@TK2MSFTNGP15.phx.gbl...
Hi There!

I'm having a mysterious error right after I login using Forms
Authentication in my ASP.NET app. Below is the error...

Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

The exception throws at the code that tries to set a property (String
data type) at my Menu user control.

When I refresh the page, the page render successfully without any
exceptions! Why?? My conclusion is that there are no exceptions in the
first place. I can't think why ASP.NET throws the exception when I
access the page for first time but not the second time! This exception
is totally unpredictable and unreasonable!

Plz help!!!

My SYS specs are...
- ASP.NET 1.1
- Windows XP (This error also occurs on Windows 2000 and Windows Server
2003 as well)

Thank you all in advance.

Max



Nov 19 '05 #13
Max,

I am going to join Kevin in his plea to post your offending code. It is
time-consuming, frustrating and sometimes impossible to debug an error from
behind a curtain. From the symptoms, it seems obvious that you are doing
something wrong in the rendering or composition of your control, but unless
we see the code, it is hard to point out where.

:DG<
"Max" <ze**@maxdot.com.com> wrote in message
news:OR**************@tk2msftngp13.phx.gbl...
Hi Kevin,

Thanks for the reply.

What I have is an ASPX page, with one Header.ascx control which accepts
comma delimited menu items (such as Menu1,Menu2,Menu3). For testing
purposes, I've created a blank ASPX page with only header ASCX control on
it and on Page_Load, I set the menu items "Menu1,Menu2,Menu3".

I refresh the page rapidly. Every two or three refresh, I get the "Object
reference not set to an instance of an object" at the point where I tried
to assign the menu item values. So I commented out that line and I tried
to access MenuBarColor property of the header control. The SAME error
produces!!! So I concluded that my Header control is not instantiated for
some reason when I do rapid refresh.

Is this normal for ASP.NET to produce this error when rapidly refreshed or
what I'm doing wrong?

max

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:er**************@TK2MSFTNGP12.phx.gbl...
The NullReferenceException indicates that you are referencing an object
in a line of code, and that the object is null, or Nothing. It is not
instantiated. If you post the line of code which throws the exception, I
can tell you all of the object references in the line of code which may
or may not be null. After that, it will be up to you to determine which,
and why.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.

"Max" <ze**@maxdot.com.com> wrote in message
news:Ox****************@TK2MSFTNGP15.phx.gbl...
Hi There!

I'm having a mysterious error right after I login using Forms
Authentication in my ASP.NET app. Below is the error...

Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

The exception throws at the code that tries to set a property (String
data type) at my Menu user control.

When I refresh the page, the page render successfully without any
exceptions! Why?? My conclusion is that there are no exceptions in the
first place. I can't think why ASP.NET throws the exception when I
access the page for first time but not the second time! This exception
is totally unpredictable and unreasonable!

Plz help!!!

My SYS specs are...
- ASP.NET 1.1
- Windows XP (This error also occurs on Windows 2000 and Windows Server
2003 as well)

Thank you all in advance.

Max



Nov 19 '05 #14

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

Similar topics

1
by: Chris Magoun | last post by:
I suddenly received an unexpected error in my project. I have been working on this project for some time without this issue. Nothing has changed in the form that caused the exception. A little...
6
by: blash | last post by:
Can someone help me? I really don't have a clue. My company staff told me they often got such error: "Object reference not set to an instance of an object." when they are in search result page...
18
by: Microsoft | last post by:
When I try this in my code I alwas get an errormessage: "Object reference not set to an instance of an object" Dim g As System.Drawing.Graphics g.DrawString("Test", New Font("Arial", 12,...
7
by: Brett | last post by:
I'm not sure why I keep getting this error, "Object reference not set to an instance of an object". Private Function somefunction() as string Dim MyCurrentClass As New Class1 Try For i As...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
4
by: rushikesh.joshi | last post by:
Hi All, I have created my own WebControl and want to add it in my aspx page at runtime. it's compiling perfectly, but when i m going to execute, it gives me error of "Object reference not set...
11
by: Spencer | last post by:
I am working on a program that uses System.Xml and an XML file. I have the following code in my project that returns a NullReferenceException: profileDataDoc = new XmlDocument();...
3
by: SAL | last post by:
I am getting the following ERROR in my WebApp on line 30: Server Error in '/TestWebApp' Application. -------------------------------------------------------------------------------- Object...
1
by: Nathan Sokalski | last post by:
I have a UserControl that I declare programmatically as follows: Dim userctrl as New rightside_portal() The codebehind file for this UserControl looks like the following: Partial Public...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.