Saturday, March 24, 2012
Object reference not set to an instance of an object
My application works fine on the localhost but spits this error as soon
as I put it on the server. I know this error occurs when an object has
not been instantiated prior to a reference, but why shouldn't it happen
in the localhost?
Here's what the the whole error msg looks like:
Server Error in '/' 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.
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
Auction002.login.UserExists() in
C:\Inetpub\wwwroot\Auction002\login.aspx.vb:82
Auction002.login.btnLogin_Click(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\Auction002\login.aspx.vb:54
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String
eventArgument) +57
System.Web.UI.Page. RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1292
----
--
Version Information: Microsoft .NET Framework Version:1.1.4322.2300;
ASP.NET Version:1.1.4322.2300
I'll really appreciate any help.
thanxHi nemo,
I cannot answer why it would happen in one environment and not in another,
as I have no idea what sort of object is being used, and for what purpose.
Neither do I know what may be different about the 2 environments or the 2
applications. Assuming that the applications are identical (and for me that
is a large assumption), it would have to be something about how the
application interacts with the enviroment.
One (of many) guess I could take would be that your app is logging in the
user with some sort of external dependency, either on Active Directory,
local machine users, or a database. Perhaps something is preventing access
to the external resource.
I would suggest you take a look at
C:\Inetpub\wwwroot\Auction002\login.aspx.vb:82
Auction002.login.btnLogin_Click(Object sender, EventArgs e)
This would be line 82 in that code file. Figure out what object references
are there, and which of them might or might not exist. If you have Visual
Studio.Net, you can set a break point there and examine the objects that are
in use. Otherwise, you can use Try/Catch to catch the exception, and perhaps
log the details of it to the Event Log.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
Paranoia is just a state of mind.
"nemo" <pallabs@.gmail.com> wrote in message
news:1125329035.242227.112120@.g47g2000cwa.googlegroups.com...
> Hi,
> My application works fine on the localhost but spits this error as soon
> as I put it on the server. I know this error occurs when an object has
> not been instantiated prior to a reference, but why shouldn't it happen
> in the localhost?
> Here's what the the whole error msg looks like:
>
> Server Error in '/' 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.
> Exception Details: System.NullReferenceException: Object reference not
> set to an instance of an object.
> Source Error:
> An unhandled exception was generated during the execution of the
> current web request. Information regarding the origin and location of
> the exception can be identified using the exception stack trace below.
>
> Stack Trace:
>
> [NullReferenceException: Object reference not set to an instance of an
> object.]
> Auction002.login.UserExists() in
> C:\Inetpub\wwwroot\Auction002\login.aspx.vb:82
> Auction002.login.btnLogin_Click(Object sender, EventArgs e) in
> C:\Inetpub\wwwroot\Auction002\login.aspx.vb:54
> System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
> System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.Raise
PostBackEvent(String
> eventArgument) +57
> System.Web.UI.Page. RaisePostBackEvent(IPostBackEventHandler
> sourceControl, String eventArgument) +18
> System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
> +33
> System.Web.UI.Page.ProcessRequestMain() +1292
>
> ----
--
> Version Information: Microsoft .NET Framework Version:1.1.4322.2300;
> ASP.NET Version:1.1.4322.2300
>
> I'll really appreciate any help.
> thanx
>
Thanks for your response Kevin. Yes the applications are identical and
I'm indeed using VS.Net. I checked line 82 in the file where the error
is occuring and here's the code:
Dim i, j As Integer
Dim UserArray() As String
UserArray = Application("userarray")
j = UserArray.Length <-- this is line 82
I have defined the application variable "userarray" in the
"Application_Start" subroutine in the global.asax file before it
reaches the above code.
Still wondering why this should not be a problem in localhost but would
in the server.
thanx
Hi nemo,
In that case, the problem lies in your setting of the
Applcation("userarray") in the Application_Start. Apparently, something is
preventing it from being created. It is probably null.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
Paranoia is just a state of mind.
"nemo" <pallabs@.gmail.com> wrote in message
news:1125333765.190206.275700@.o13g2000cwo.googlegroups.com...
> Thanks for your response Kevin. Yes the applications are identical and
> I'm indeed using VS.Net. I checked line 82 in the file where the error
> is occuring and here's the code:
> Dim i, j As Integer
> Dim UserArray() As String
> UserArray = Application("userarray")
> j = UserArray.Length <-- this is line 82
>
> I have defined the application variable "userarray" in the
> "Application_Start" subroutine in the global.asax file before it
> reaches the above code.
> Still wondering why this should not be a problem in localhost but would
> in the server.
> thanx
>
Object reference not set to an instance of an object
My application works fine on the localhost but spits this error as soon
as I put it on the server. I know this error occurs when an object has
not been instantiated prior to a reference, but why shouldn't it happen
in the localhost?
Here's what the the whole error msg looks like:
Server Error in '/' 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.
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
Auction002.login.UserExists() in
C:\Inetpub\wwwroot\Auction002\login.aspx.vb:82
Auction002.login.btnLogin_Click(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\Auction002\login.aspx.vb:54
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1292
------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2300;
ASP.NET Version:1.1.4322.2300
I'll really appreciate any help.
thanxHi nemo,
I cannot answer why it would happen in one environment and not in another,
as I have no idea what sort of object is being used, and for what purpose.
Neither do I know what may be different about the 2 environments or the 2
applications. Assuming that the applications are identical (and for me that
is a large assumption), it would have to be something about how the
application interacts with the enviroment.
One (of many) guess I could take would be that your app is logging in the
user with some sort of external dependency, either on Active Directory,
local machine users, or a database. Perhaps something is preventing access
to the external resource.
I would suggest you take a look at
C:\Inetpub\wwwroot\Auction002\login.aspx.vb:82
Auction002.login.btnLogin_Click(Object sender, EventArgs e)
This would be line 82 in that code file. Figure out what object references
are there, and which of them might or might not exist. If you have Visual
Studio.Net, you can set a break point there and examine the objects that are
in use. Otherwise, you can use Try/Catch to catch the exception, and perhaps
log the details of it to the Event Log.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Paranoia is just a state of mind.
"nemo" <pallabs@.gmail.com> wrote in message
news:1125329035.242227.112120@.g47g2000cwa.googlegr oups.com...
> Hi,
> My application works fine on the localhost but spits this error as soon
> as I put it on the server. I know this error occurs when an object has
> not been instantiated prior to a reference, but why shouldn't it happen
> in the localhost?
> Here's what the the whole error msg looks like:
>
> Server Error in '/' 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.
> Exception Details: System.NullReferenceException: Object reference not
> set to an instance of an object.
> Source Error:
> An unhandled exception was generated during the execution of the
> current web request. Information regarding the origin and location of
> the exception can be identified using the exception stack trace below.
>
> Stack Trace:
>
> [NullReferenceException: Object reference not set to an instance of an
> object.]
> Auction002.login.UserExists() in
> C:\Inetpub\wwwroot\Auction002\login.aspx.vb:82
> Auction002.login.btnLogin_Click(Object sender, EventArgs e) in
> C:\Inetpub\wwwroot\Auction002\login.aspx.vb:54
> System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
> System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
> eventArgument) +57
> System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
> sourceControl, String eventArgument) +18
> System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
> +33
> System.Web.UI.Page.ProcessRequestMain() +1292
>
> ------------------------
> Version Information: Microsoft .NET Framework Version:1.1.4322.2300;
> ASP.NET Version:1.1.4322.2300
>
> I'll really appreciate any help.
> thanx
Thanks for your response Kevin. Yes the applications are identical and
I'm indeed using VS.Net. I checked line 82 in the file where the error
is occuring and here's the code:
Dim i, j As Integer
Dim UserArray() As String
UserArray = Application("userarray")
j = UserArray.Length <-- this is line 82
I have defined the application variable "userarray" in the
"Application_Start" subroutine in the global.asax file before it
reaches the above code.
Still wondering why this should not be a problem in localhost but would
in the server.
thanx
Hi nemo,
In that case, the problem lies in your setting of the
Applcation("userarray") in the Application_Start. Apparently, something is
preventing it from being created. It is probably null.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Paranoia is just a state of mind.
"nemo" <pallabs@.gmail.com> wrote in message
news:1125333765.190206.275700@.o13g2000cwo.googlegr oups.com...
> Thanks for your response Kevin. Yes the applications are identical and
> I'm indeed using VS.Net. I checked line 82 in the file where the error
> is occuring and here's the code:
> Dim i, j As Integer
> Dim UserArray() As String
> UserArray = Application("userarray")
> j = UserArray.Length <-- this is line 82
>
> I have defined the application variable "userarray" in the
> "Application_Start" subroutine in the global.asax file before it
> reaches the above code.
> Still wondering why this should not be a problem in localhost but would
> in the server.
> thanx
Thursday, March 22, 2012
Object reference not set to an instance of an object working in debug mode but not in IIS
Hi have this funny error, working fine when I debug the project in debug mode but has the above error in localhost.
All the page works fine but only one with this error... Anyone know how to solve this problem?
cheers
Hello my friend,
Could you provide some source code and the error details that you get, line number, etc?
Kind regards
Scotty
Hi Scotty,
Sorry for the late reply... I do not know which part of the source code that cause this problem cause when I'm trying to track this error through debug mode, but the program just works fine.
When i try accessing it through the localhost, it just pop up a alert stating the above error...
cheers
hi,
do you have virtual directory in IIS? if no, create it. if yes, provide your full code. so that it will be easy to find out the error.
HiXpy,
Based on my understanding, your web application runs fine with Visual Studio in the debug mode, but when you run it in localhost you get the "Object reference not set to an instance of an object" error message. If I have misunderstood you, please feel free to tell me.
If we run this web application in the localhost on another machine, does it have the same issue?
There are many causes of that this error message will be appear. It is difficult to find the cause without debugger. Please check the code of the page which displays error message and see if there is a mistake or defect in the code.
You can also debug the web application in the localhost with Just-In-Time debugging which is the feature of Visual Studio 2005 Debugger. When a crash occurs with Just-In-Time Debugging enabled, a dialog box appears and then you can choose the Debugger to debug your web application. For more information, seeJust-In-Time Debugging.
I hope this helps.
i agree with the above post you can get this reason because of many reasons which is difficult to find out without debugging, this error is mainly becuase you are using an object without assingin a value or without initializing that object in the code...so check carefully that all the objects are properly intitialized.
Hi Thomas,
Thanks for the feedback, sorry for not getting back... Been quite bz with work so totally forgotten abt this error.. Will try it out and get back... By the way its an application which runs in my office machine, IIS and even server... But when I tried it on my home machine, this error pop up only in one page... Therefore I guess i will need to look in the codes of this particular page...
Thanks all for the feedback
cheers