By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,677 Members | 1,890 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,677 IT Pros & Developers. It's quick & easy.

sometimes we get Object reference to NULL error

P: n/a
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 then tried to access 2nd, or 3rd, etc page. The problem is it
happens sometimes - sometimes when they clicked refresh button, then
everything is ok. Now they told me it happens more frequently. but I
have tried by myself many times and never got such error.

I can't understand why it is not happening all the time? I even
suspected it is network problem, we tried to login to the web server
from different computers at same time and tried the same web url -
localhost then he got the error while I don't. Then what could be?
here is the error message:

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

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

Source Error:
Line 51: <TD><IMG height=1
src='<%=ResolveUrl("../../../RPI/Images/Spacer.gif")%>' width=5 ></TD>
Line 52: <TD valign="top"
align=left width=100%>
Line 53:
<ASP:PLACEHOLDER id="Content" runat="Server" />
Line 54: </TD>
Line 55: </TR>

Source File: H:\NewRPI\CompanyStarterKit\Companies\Common\Theme s\NewRPI\Skins\PageSkins\Default.ascx
Line: 53

Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
ASPNET.StarterKit.Companies.ItemCandidateDateCreat ed.RenderContents(HtmlTextWriter
writer)
System.Web.UI.WebControls.WebControl.Render(HtmlTe xtWriter writer)
+29
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
ASPNET.StarterKit.Companies.ContentList.RenderCont ents(HtmlTextWriter
writer)
System.Web.UI.WebControls.WebControl.Render(HtmlTe xtWriter writer)
+29
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +72
System.Web.UI.WebControls.WebControl.RenderContent s(HtmlTextWriter
writer) +7
System.Web.UI.WebControls.WebControl.Render(HtmlTe xtWriter writer)
+29
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +72
System.Web.UI.WebControls.WebControl.RenderContent s(HtmlTextWriter
writer) +7
System.Web.UI.WebControls.WebControl.Render(HtmlTe xtWriter writer)
+29
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
ASP.Default_ascx.__Render__control1(HtmlTextWriter __output,
Control parameterContainer) in
H:\NewRPI\CompanyStarterKit\Companies\Common\Theme s\NewRPI\Skins\PageSkins\Default.ascx:53
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +27
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +72
System.Web.UI.HtmlControls.HtmlForm.RenderChildren (HtmlTextWriter
writer) +44
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTex tWriter output)
+262
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Page.ProcessRequestMain() +1912

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.4322.573;
ASP.NET Version:1.1.4322.573
Nov 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi,

The problem appears to be with whatever you are placing in here:

<ASP:PLACEHOLDER id="Content" runat="Server" />

Can you post some code showing how you fill this? The Default.ascx page
shown probably doesn't have a problem itself. With the code to show how you
are filling the placeholder we can maybe come up with an error capture
schema that can help you narrow this down. Also, since it is happening more
frequently do you have web statistics available for your server? If so,
running a few custom reports using a "daily" period may also help you narrow
this down because if you can view them in a graph you may be able to see
what is suddenly being hit more frequently.

Finally, the most common source of this problem is using an object that
hasn't been set to anything. If you are using VB then it would be because
the New keyword was forgotten. Are you filling your placeholder with
another .ascx page? If so grab a text search utility that let's you search
based on the proximity of two search phrases. Then search all of the code
behind files for your .ascx pages using the proximity between the words
"Dim" & "New", "Private" & "New", "Public" & "New", "Protected" &
"New"...etc. Search for it to give a hit when it finds the first work (i.e.
"Dim") but not the second word ("New") within ~50 charachters. That should
at least find you the source of the problem although you may need to do a
lot of checking depending on the size of your project.

Those are all the solutions I can come up with right now. This at least is
how I approach the problem head on. The code filling that placeholder will
provide us with more ways to figure this out. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"blash" <bl*************@yahoo.com> wrote in message
news:23*************************@posting.google.co m...
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 then tried to access 2nd, or 3rd, etc page. The problem is it
happens sometimes - sometimes when they clicked refresh button, then
everything is ok. Now they told me it happens more frequently. but I
have tried by myself many times and never got such error.

I can't understand why it is not happening all the time? I even
suspected it is network problem, we tried to login to the web server
from different computers at same time and tried the same web url -
localhost then he got the error while I don't. Then what could be?
here is the error message:

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

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

Source Error:
Line 51: <TD><IMG height=1
src='<%=ResolveUrl("../../../RPI/Images/Spacer.gif")%>' width=5 ></TD>
Line 52: <TD valign="top"
align=left width=100%>
Line 53:
<ASP:PLACEHOLDER id="Content" runat="Server" />
Line 54: </TD>
Line 55: </TR>

Source File: H:\NewRPI\CompanyStarterKit\Companies\Common\Theme s\NewRPI\Skins\PageSkins\D
efault.ascx Line: 53

Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
ASPNET.StarterKit.Companies.ItemCandidateDateCreat ed.RenderContents(HtmlText
Writer writer)
System.Web.UI.WebControls.WebControl.Render(HtmlTe xtWriter writer)
+29
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
ASPNET.StarterKit.Companies.ContentList.RenderCont ents(HtmlTextWriter
writer)
System.Web.UI.WebControls.WebControl.Render(HtmlTe xtWriter writer)
+29
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +72
System.Web.UI.WebControls.WebControl.RenderContent s(HtmlTextWriter
writer) +7
System.Web.UI.WebControls.WebControl.Render(HtmlTe xtWriter writer)
+29
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +72
System.Web.UI.WebControls.WebControl.RenderContent s(HtmlTextWriter
writer) +7
System.Web.UI.WebControls.WebControl.Render(HtmlTe xtWriter writer)
+29
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
ASP.Default_ascx.__Render__control1(HtmlTextWriter __output,
Control parameterContainer) in
H:\NewRPI\CompanyStarterKit\Companies\Common\Theme s\NewRPI\Skins\PageSkins\D
efault.ascx:53 System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +27
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +72
System.Web.UI.HtmlControls.HtmlForm.RenderChildren (HtmlTextWriter
writer) +44
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTex tWriter output)
+262
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Page.ProcessRequestMain() +1912

-------------------------------------------------------------------------- ------
Version Information: Microsoft .NET Framework Version:1.1.4322.573;
ASP.NET Version:1.1.4322.573

Nov 19 '05 #2

P: n/a
blash..
The error is difficult to tackle..
I'm sure ur just missing something simple in ur application..
Something is not being SET or maybe declared
What is ur code really doing at this point i can see its a SRC to
retrieve images!!Whats ResolveUrl? :-
<%=ResolveUrl("../../../RPI/Images/Spacer.gif")%>
Elaborate more ...
Patrick
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #3

P: n/a
Thanks for so quick response.

I just checked the code as you suggested, it turns out the viewstate
problem. The code uses viewstate without checking whether it is null.
However, even I add the part - if the viewstate is not null then do the
following - I still haven't solved this issue.
Viewstate disappears sometime !

why?

Nov 19 '05 #4

P: n/a
That part works fine. I checked the trace log, it loads the file
correctly.

Nov 19 '05 #5

P: n/a
That part works fine. I checked the trace and it got the file correctly.

Nov 19 '05 #6

P: n/a
Hi,

I wish I could help you further but with the information you provided I
can't. I still can't see what is happening. How did you determine the
viewstate is missing? Were you able to nail this down to a portion of code
where this is happening? Is it happening in the placeholder? There are
just way to many unknowns. Try to nail down Where(code) and
When(conditions) this happens. Then we can come up with a solution. Good
luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

<bl*************@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Thanks for so quick response.

I just checked the code as you suggested, it turns out the viewstate
problem. The code uses viewstate without checking whether it is null.
However, even I add the part - if the viewstate is not null then do the
following - I still haven't solved this issue.
Viewstate disappears sometime !

why?

Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.