ASP.NET错误:Object reference not set to an instance of an object

来源:百度知道 编辑:UC知道 时间:2024/09/21 00:32:38
望高手解答,追100分,谢谢!

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.]
HelloUser.Page_Load(Object sender, EventArgs e) in d:\Work\TpInternationalSln\Tp

在那里引用对象的时候没有实例化,或者使用了null变量。只能单步跟踪了,看看问题在那里!

Server Error in '/' Application

是不是有路径的问题哦,像楼下说的设断点,看代码错误的位置在哪里?

这样的错误是因为使用了某个为null的变量,解决方法是调试的时候查看发生错误的断点,看哪个变量为null。
单单看上面的错误信息不能找出错误,你要把发生断点的代码帖上来。