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.NullRefe renceException: 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 13 2439
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.NullRefe renceException: 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
The NullReferenceEx ception 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.co m.com> wrote in message
news:Ox******** ********@TK2MSF TNGP15.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.NullRefe renceException: 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
Inside the Page_Load function on the page i believe there is a
if(!Page.IsPost Back)
that is loading the Object. Look there.
Kevin Spencer wrote: The NullReferenceEx ception 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.co m.com> wrote in message news:Ox******** ********@TK2MSF TNGP15.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.NullRefe renceException: 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
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.goo glegroups.com.. . Inside the Page_Load function on the page i believe there is a if(!Page.IsPost Back) that is loading the Object. Look there. Kevin Spencer wrote: The NullReferenceEx ception 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.co m.com> wrote in message news:Ox******** ********@TK2MSF TNGP15.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.NullRefe renceException: 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 >
I think Navajo is right... the problem lies in 'if(!Page.IsPos tBack)' 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.IsPos tBack) {...}'. 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.IsPos tBack)' 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.goo glegroups.com.. . Inside the Page_Load function on the page i believe there is a if(!Page.IsPost Back) that is loading the Object. Look there. Kevin Spencer wrote: The NullReferenceEx ception 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.co m.com> wrote in message news:Ox******** ********@TK2MSF TNGP15.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.NullRefe renceException: 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 >
but yeah one should be really cautious putting some code outside
'if(!Page.IsPos tBack)' as it may have negetive impact on performance.
"Yatendra Khandelwal" wrote: I think Navajo is right... the problem lies in 'if(!Page.IsPos tBack)' 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.IsPos tBack) {...}'. 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.IsPos tBack)' 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.goo glegroups.com.. . Inside the Page_Load function on the page i believe there is a if(!Page.IsPost Back) that is loading the Object. Look there. Kevin Spencer wrote: > The NullReferenceEx ception 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.co m.com> wrote in message > news:Ox******** ********@TK2MSF TNGP15.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.NullRefe renceException: 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 > >
I did that and the same exception thrown when I refresh the page repadily.
max
"cmay" <cm**@discussio ns.microsoft.co m> wrote in message
news:B5******** *************** ***********@mic rosoft.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.NullRefe renceException: 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
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,Men u3). 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,Me nu3".
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***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:er******** ******@TK2MSFTN GP12.phx.gbl... The NullReferenceEx ception 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.co m.com> wrote in message news:Ox******** ********@TK2MSF TNGP15.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.NullRefe renceException: 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
Hi Yatendra,
My page does not utilize the Page.IsPostBack .
max
"Yatendra Khandelwal" <ya************ *****@ishisyste ms.com.(donotsp am)>
wrote in message news:14******** *************** ***********@mic rosoft.com... I think Navajo is right... the problem lies in 'if(!Page.IsPos tBack)' 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.IsPos tBack) {...}'. 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.IsPos tBack)' 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.goo glegroups.com.. . > Inside the Page_Load function on the page i believe there is a > if(!Page.IsPost Back) > that is loading the Object. Look there. > > > > Kevin Spencer wrote: >> The NullReferenceEx ception 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.co m.com> wrote in message >> news:Ox******** ********@TK2MSF TNGP15.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.NullRefe renceException: 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 >> > > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 experimentation shows that I cannot
run ANY .NET web project without getting this error:
----------------------------------------------------------------------------
----
Object reference not set to an instance of an object.
|
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 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...
|
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, FontStyle.Bold), Brushes.Black,
0, 0)
Why is this?
Marc
|
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 Integer = 0 To LinkResults.Length - 1
With MyCurrentClass.SqlCmd_Insert_LinkVB
.CommandType = System.Data.CommandType.StoredProcedure
|
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 path of the uploaded image, and resize it with the provided dimensions. My function is below. The current function is returning an error when run from the upload function: A generic error occurred in GDI+. Not sure what exactly that means. From what...
| |
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 to an instance of an object." in my
server control (ascx.cs file)
|
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();
profileDataDoc.Load(fileName);
XmlElement root = profileDataDoc.DocumentElement;
XmlNode GoalNode = root.SelectSingleNode("/Profile_Data/Profile
|
by: SAL |
last post by:
I am getting the following ERROR in my WebApp on line 30:
Server Error in '/TestWebApp' Application.
--------------------------------------------------------------------------------
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.
|
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 Class rightside_portal : Inherits System.Web.UI.UserControl
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |