473,418 Members | 2,337 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.

sometimes we get Object reference to NULL error

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
6 6092
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
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
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
That part works fine. I checked the trace log, it loads the file
correctly.

Nov 19 '05 #5
That part works fine. I checked the trace and it got the file correctly.

Nov 19 '05 #6
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ersin Gençtürk | last post by:
We couldn't find why these errors happen.They doesn't appear everytime.And they appear different pages at different times.Is there somebody know why these happenes ? First user gets this error :...
4
by: Manny Chohan | last post by:
Hi Guys, been puzzled with this error for few days now. In the try and catch block, i am trying to set the label text property to property retrieved from exchange database. The record has...
2
by: Ben | last post by:
I have several pages written in aspx, but sometime the aspx page return the following error. And it hapeen, the whole web application gives this error, that means all the aspx files get affected....
3
by: Adriano | last post by:
Hello, when I try to print something, either DataGrid or from Crystal Report viever the folowing error message appears and cancels printing: Object reference not set to an instance of an...
12
by: Andrew Poulos | last post by:
With the following code I can't understand why this.num keeps incrementing each time I create a new instance of Foo. For each instance I'm expecting this.num to alert as 1 but keeps incrementing. ...
8
by: Charlie J | last post by:
I have a real stumper. I added a server side table to a home page that has two other server side tables on it that have been working great. In Visual Studio everything works great. When I put...
3
by: SAL | last post by:
I am getting the following ERROR in my WebApp on line 30: Server Error in '/TestWebApp' Application. -------------------------------------------------------------------------------- Object...
7
by: TS | last post by:
I was under the assumption that if you pass an object as a param to a method and inside that method this object is changed, the object will stay changed when returned from the method because the...
2
by: Ralph | last post by:
Hi I don't understand why it's not working: function schedule(imTop){ this.tdImagesTop = imTop; } schedule.prototype.selectEl = function() { alert(this.tdImagesTop);
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.