Thursday, March 22, 2012

Object reference not set to an instance of an object error

A web form in my app is not running anymore. Whenever I try to do an action,
I get an error:

Server Error in '/codelib' Application.
-----------------------
--
Object reference not set to an instance of an object.

weird thing is that I just posted this app live yesterday and it works fine
on my web host. I try to run it from VS.Net and I can't.
Commenting out various code lines does not help. Even the simplest actions
return the same error.

Why would this occur and how can I fix it?

I'm using .net 1.0.Ok, I think the error was because the dropdown list had nothing in it and
the code was trying to use a value from it.

I had assumed the Page_Load event was getting triggered (which is is not).

Interesting, the Page_Load event is working on my host, but not in VS.Net.

I am wondering if it has anything to do with the extra code that VS.Net
adds. I see a difference between the version I did w/o VS.Net and the VS.Net
version. VS.Net adds more code:

For example in VS.Net I see:
Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load

but in the notepad version this suffices:

Sub Page_Load(Source As Object, E As EventArgs)

I suppose the framework does not require all of the additional code that
VS.Net adds?

At least it is working now.

"Tim Zych" <tzych@.earth_noworms_link_dotttt.net> wrote in message
news:O#mF1jcOEHA.2716@.tk2msftngp13.phx.gbl...
> A web form in my app is not running anymore. Whenever I try to do an
action,
> I get an error:
> Server Error in '/codelib' Application.
> -----------------------
--
> --
> Object reference not set to an instance of an object.
>
> weird thing is that I just posted this app live yesterday and it works
fine
> on my web host. I try to run it from VS.Net and I can't.
> Commenting out various code lines does not help. Even the simplest actions
> return the same error.
> Why would this occur and how can I fix it?
> I'm using .net 1.0.
I'm not sure about VB.NET, but when editing ASP.NET files in C# VS.NET loves
to erase event handlers.

"Tim Zych" <tzych@.earth_noworms_link_dotttt.net> wrote in message
news:u%23KBmggOEHA.3044@.TK2MSFTNGP10.phx.gbl...
> Ok, I think the error was because the dropdown list had nothing in it and
> the code was trying to use a value from it.
> I had assumed the Page_Load event was getting triggered (which is is not).
> Interesting, the Page_Load event is working on my host, but not in VS.Net.
> I am wondering if it has anything to do with the extra code that VS.Net
> adds. I see a difference between the version I did w/o VS.Net and the
VS.Net
> version. VS.Net adds more code:
> For example in VS.Net I see:
> Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
> Handles MyBase.Load
> but in the notepad version this suffices:
> Sub Page_Load(Source As Object, E As EventArgs)
> I suppose the framework does not require all of the additional code that
> VS.Net adds?
> At least it is working now.
>
> "Tim Zych" <tzych@.earth_noworms_link_dotttt.net> wrote in message
> news:O#mF1jcOEHA.2716@.tk2msftngp13.phx.gbl...
> > A web form in my app is not running anymore. Whenever I try to do an
> action,
> > I get an error:
> > Server Error in '/codelib' Application.
> -----------------------
> --
> > --
> > Object reference not set to an instance of an object.
> > weird thing is that I just posted this app live yesterday and it works
> fine
> > on my web host. I try to run it from VS.Net and I can't.
> > Commenting out various code lines does not help. Even the simplest
actions
> > return the same error.
> > Why would this occur and how can I fix it?
> > I'm using .net 1.0.
>

0 comments:

Post a Comment