^0^求救.........运行时提示这样的错误!!!!!

zhuyunping 2005-08-17 01:31:33
“/bgzdh”应用程序中的服务器错误。
--------------------------------------------------------------------------------

未将对象引用设置到对象的实例。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

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

源错误:


行 36: if (this.IsPostBack)
行 37: return;
行 38: if( this.Session["Flag"].ToString() == "1" )
行 39: {
行 40: cxtj = "01";


源文件: c:\inetpub\wwwroot\bgzdh\w_mainmeun_wqz.aspx.cs 行: 38

堆栈跟踪:


[NullReferenceException: 未将对象引用设置到对象的实例。]
bgzdh.W_mainmeun_wqz.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\bgzdh\w_mainmeun_wqz.aspx.cs:38
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()




--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573
...全文
112 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhuyunping 2005-08-21
  • 打赏
  • 举报
回复
有没有人在呀?????
我的问题还没解决呢!!!!
其实我在这个出错页面下做一个TREEVIEW可是死活不显示
freedoms_sj 2005-08-17
  • 打赏
  • 举报
回复
=。= 错误原因很简单 null 不能 ToString()呀
zhuyunping 2005-08-17
  • 打赏
  • 举报
回复
这个地方判断了!!!没效果
行 83: string name = this.Session["username"].ToString().Trim() ;
同样要在trim之前判断是否为空.
还是提示这个
“/bgzdh”应用程序中的服务器错误。
未将对象引用设置到对象的实例。

zhuyunping 2005-08-17
  • 打赏
  • 举报
回复
谢谢各位改了之后好多了现在还提示:
“/bgzdh”应用程序中的服务器错误。
未将对象引用设置到对象的实例。
aibo7 2005-08-17
  • 打赏
  • 举报
回复
2个地方有可能出错:
一个就是上面兄弟们说的if( this.Session["Flag"].ToString() == "1" )
之前要判断是否为空。

另一个地方就是这里:
行 83: string name = this.Session["username"].ToString().Trim() ;
同样要在trim之前判断是否为空.
zhuyunping 2005-08-17
  • 打赏
  • 举报
回复
这是出错的程序段
if( this.Session["Flag"].ToString() == "1" )
{
cxtj = "01";
// Label2.Text = " 发文管理 " ;
Image2.ImageUrl = "images/a1.jpg" ;
}
else
{
cxtj = this.Session["PartId"].ToString().Trim() ;
cxtj = cxtj + "" ;

if(cxtj.Trim() == "01")
{
Image2.ImageUrl = "images/a1.jpg" ;
}
if(cxtj.Trim() == "02")
{
Image2.ImageUrl = "images/a2.jpg" ;
}
if(cxtj.Trim() == "03")
{
Image2.ImageUrl = "images/a3.jpg" ;
}
if(cxtj == "04")
{
Image2.ImageUrl = "images/a4.jpg" ;
}
if(cxtj == "05")
{
Image2.ImageUrl = "images/a5.jpg" ;
}
if(cxtj == "06")
{
Image2.ImageUrl = "images/a6.jpg" ;
}
if(cxtj == "08")
{
Image2.ImageUrl = "images/a9.jpg" ;
}
}
zhuyunping 2005-08-17
  • 打赏
  • 举报
回复
改了之后出现如下提示
“/bgzdh”应用程序中的服务器错误。
--------------------------------------------------------------------------------

未将对象引用设置到对象的实例。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

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

源错误:


行 81: }
行 82: }
行 83: string name = this.Session["username"].ToString().Trim() ;
行 84: name = name + "" ;
行 85: Label1.Text = " 欢迎你:" + name.Trim() ;


源文件: c:\inetpub\wwwroot\bgzdh\w_mainmeun_wqz.aspx.cs 行: 83

堆栈跟踪:


[NullReferenceException: 未将对象引用设置到对象的实例。]
bgzdh.W_mainmeun_wqz.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\bgzdh\w_mainmeun_wqz.aspx.cs:83
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()




--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573
zhuyunping 2005-08-17
  • 打赏
  • 举报
回复
出错代码如下:

if( this.Session["Flag"].ToString() == "1" )
{
cxtj = "01";
// Label2.Text = " 发文管理 " ;
Image2.ImageUrl = "images/a1.jpg" ;
}
else
{
cxtj = this.Session["PartId"].ToString().Trim() ;
cxtj = cxtj + "" ;

if(cxtj.Trim() == "01")
{
Image2.ImageUrl = "images/a1.jpg" ;
}
if(cxtj.Trim() == "02")
{
Image2.ImageUrl = "images/a2.jpg" ;
}
if(cxtj.Trim() == "03")
{
Image2.ImageUrl = "images/a3.jpg" ;
}
if(cxtj == "04")
{
Image2.ImageUrl = "images/a4.jpg" ;
}
if(cxtj == "05")
{
Image2.ImageUrl = "images/a5.jpg" ;
}
if(cxtj == "06")
{
Image2.ImageUrl = "images/a6.jpg" ;
}
if(cxtj == "08")
{
Image2.ImageUrl = "images/a9.jpg" ;
}
}
silverseven7 2005-08-17
  • 打赏
  • 举报
回复
if(Session["Flag"]!=null)
{
if(Session["Flag"].ToString()=="1")
{

}
}
amendajing 2005-08-17
  • 打赏
  • 举报
回复
this.Session["Flag"]去用时判断一下
if(this.Session["Flag"]!=null)
{
}
haibuo1981 2005-08-17
  • 打赏
  • 举报
回复
你误会jinjazz的意思了
先要判断Session不为空

你该这么写
if(Session["Flag"]!=null)
{
if(Session["Flag"].ToString()=="1")
{
//你的操作
}
}
TechEye 2005-08-17
  • 打赏
  • 举报
回复
if (this.IsPostBack)
return;
if( this.Session["Flag"] != null)
{
if (Session["Flag"].ToString() == "1")
{
//这里再加入代码
}
}
zhuyunping 2005-08-17
  • 打赏
  • 举报
回复
"this.Session["Flag"] 返了回null"改了之后返回这样的错误
“/bgzdh”应用程序中的服务器错误。
--------------------------------------------------------------------------------

未将对象引用设置到对象的实例。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

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

源错误:


行 36: if (this.IsPostBack)
行 37: return;
行 38: if( this.Session["Flag"].ToString() == "null" )
行 39: {
行 40: cxtj = "01";


源文件: c:\inetpub\wwwroot\bgzdh\w_mainmeun_wqz.aspx.cs 行: 38

堆栈跟踪:


[NullReferenceException: 未将对象引用设置到对象的实例。]
bgzdh.W_mainmeun_wqz.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\bgzdh\w_mainmeun_wqz.aspx.cs:38
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()




--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573
jinjazz 2005-08-17
  • 打赏
  • 举报
回复
this.Session["Flag"] 返了回null吧

110,549

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧