神秘错误:未将对象引用设置为对象的实例 [英] Mysterious Error: Object reference not set to an instance of an object

查看:83
本文介绍了神秘错误:未将对象引用设置为对象的实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!


我在ASP.NET应用程序中使用表单身份验证

后立即发生了一个神秘的错误。以下是错误...


异常详细信息:System.NullReferenceException:未设置对象引用

到对象的实例。


在我的菜单用户控件上尝试设置属性(字符串数据

类型)的代码抛出异常。


当我刷新页面时,页面呈现成功,没有任何

异常!为什么??我的结论是,在第一个

的地方没有例外。当我第一次访问页面

而不是第二次访问页面时,我无法想到为什么ASP.NET会抛出异常!这个例外完全不可预测且不合理!


Plz帮助!!!


我的SYS规格是。 ..

- ASP.NET 1.1

- Windows XP(Windows 2000和Windows Server 2003上也会出现此错误




提前谢谢大家。


Max

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.NullReferenceException: 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

推荐答案

可能没有帮助,但是当我试图访问网页用户控件的公共属性时,我遇到了类似的问题(我认为这就是所谓的......)

ASCX控制)。


出于某种原因,控件无法正确实例化,或者正确回发




我以与第一页完全相同的方式创建了第二页,复制了

代码并且它有效。我删除了第一页,将第2页改名为右边

名称并继续使用。


如果你创建一个全新的页面,除了你的控制之外什么都没有它是否会失败



" Max"写道:
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:
你好!

我在ASP.NET应用程序中使用表单身份验证后立即发生了一个神秘的错误
。以下是错误...

异常详细信息:System.NullReferenceException:对象引用未设置为对象的实例。

异常抛出尝试在我的菜单用户控件上设置属性(字符串数据类型)的代码。

当我刷新页面时,页面呈现成功,没有任何例外!为什么??我的结论是第一个地方没有例外。当我第一次访问页面时,我无法想到为什么ASP.NET会抛出异常,而不是第二次!这个例外完全不可预测且不合理!

Plz帮助!!!

我的SYS规格是......
- ASP.NET 1.1
- Windows XP(Windows 2000和Windows Server 2003上也会出现此错误)

提前谢谢大家。

Max
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.NullReferenceException: 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



NullReferenceException表示您正在引用

代码行中的对象,并且该对象为null , 或无。它不是实例化的b $ b。如果你发布了引发异常的代码行,我可以告诉你代码行中的所有对象引用,这些对象引用可能或者可能是
不是null。在那之后,由你来决定哪个以及为什么。


-

HTH,


Kevin Spencer

Microsoft MVP

..Net开发人员

无论是关注者还是贷方都不是。


" Max" <泽** @ maxdot.com.com>在消息中写道

新闻:Ox **************** @ TK2MSFTNGP15.phx.gbl ...
The NullReferenceException 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.com.com> wrote in message
news:Ox****************@TK2MSFTNGP15.phx.gbl...
你好!

我在ASP.NET应用程序中使用Forms
身份验证后立即发生了一个神秘的错误。以下是错误...

异常详细信息:System.NullReferenceException:对象引用未设置为对象的实例。

异常抛出尝试在我的菜单用户控件上设置属性(字符串数据类型)的代码。

当我刷新页面时,页面呈现成功,没有任何例外!为什么??我的结论是,首先没有例外。当我第一次访问页面而不是第二次访问页面时,我无法想到为什么ASP.NET会抛出异常!这个例外完全不可预测且不合理!

Plz帮助!!!

我的SYS规格是......
- ASP.NET 1.1
- Windows XP(此错误也发生在Windows 2000和Windows Server上,2003年也是如此)

提前谢谢大家。

Max
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.NullReferenceException: 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



在页面上的Page_Load函数内我相信有一个

if(!Page.IsPostBack)

正在加载Object。看看那里。


Kevin Spencer写道:
Inside the Page_Load function on the page i believe there is a
if(!Page.IsPostBack)
that is loading the Object. Look there.

Kevin Spencer wrote:
NullReferenceException表示你在一行代码中引用
对象,并且该对象是null,或Nothing。它没有实例化。如果你发布了抛出
异常的代码行,我可以告诉你代码行中的所有对象引用,它们可能是
或者可能不是null。在那之后,由你决定哪个,以及
为什么。
-
HTH,

Kevin Spencer
微软MVP
.Net开发人员
跟随者和贷方都不是。

最大 <泽** @ maxdot.com.com>在消息中写道
新闻:Ox **************** @ TK2MSFTNGP15.phx.gbl ...
The NullReferenceException 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.com.com> wrote in message
news:Ox****************@TK2MSFTNGP15.phx.gbl...
你好!

我在ASP.NET应用程序中使用Forms
身份验证后立即发生了一个神秘的错误。以下是错误...

异常详细信息:System.NullReferenceException:对象引用
未设置为对象的实例。

异常抛出试图在我的菜单用户控件上设置属性
(字符串数据类型)的代码。

当我刷新页面时,页面呈现成功,没有任何例外!为什么??我的结论是,
首先没有例外。当我第一次访问该页面而不是第二次访问该页面时,我无法想象为什么ASP.NET会抛出异常!这个例外是
完全不可预测和不合理!

Plz帮助!!!

我的SYS规格是......
- ASP.NET 1.1
- Windows XP(此错误也发生在Windows 2000和Windows
Server 2003上)

提前谢谢大家。

Max
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.NullReferenceException: 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






这篇关于神秘错误:未将对象引用设置为对象的实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆