sometimes we get Object reference to NULL error

B

blash

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\Themes\NewRPI\Skins\PageSkins\Default.ascx
Line: 53

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an
object.]
ASPNET.StarterKit.Companies.ItemCandidateDateCreated.RenderContents(HtmlTextWriter
writer)
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
+29
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
ASPNET.StarterKit.Companies.ContentList.RenderContents(HtmlTextWriter
writer)
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
+29
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter
writer) +7
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
+29
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter
writer) +7
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
+29
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWriter 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\Themes\NewRPI\Skins\PageSkins\Default.ascx:53
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +27
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter
writer) +44
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)
+262
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Page.ProcessRequestMain() +1912
 
K

Ken Dopierala Jr.

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 said:
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\Themes\NewRPI\Skins\PageSkins\D
efault.ascx
Line: 53

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an
object.]
ASPNET.StarterKit.Companies.ItemCandidateDateCreated.RenderContents(HtmlText
Writer
writer)
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
+29
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
ASPNET.StarterKit.Companies.ContentList.RenderContents(HtmlTextWriter
writer)
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
+29
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter
writer) +7
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
+29
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter
writer) +7
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
+29
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWriter 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\Themes\NewRPI\Skins\PageSkins\D
efault.ascx:53
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +27
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter
writer) +44
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)
+262
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWriter 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
 
P

Patrick Olurotimi Ige

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
 
B

blashblashblash

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?
 
B

blashblashblash

That part works fine. I checked the trace log, it loads the file
correctly.
 
K

Ken Dopierala Jr.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top