又是一个经典的Object reference not set to an instance of an object.
我的网站在本机调试正常 
 发布到IIS刚开始也正常 
 可是过了一晚上,就不能登陆         每次都是这样:时间一长久变得不能登陆 
 ,我查了一下,有两个函数的返回值可能为空,对此我全部修改过了,可还是有这个问题 
 错误信息:   
 Stack   Trace:   
 [NullReferenceException:   Object   reference   not   set   to   an   instance   of   an   object.] 
          MySql.Data.MySqlClient.NativeDriver.Configure(MySqlConnection   connection)   +20 
          MySql.Data.MySqlClient.MySqlConnection.Open()   +276 
          DBUtility.PrepareCommand(MySqlCommand   cmd,   MySqlConnection   conn,   MySqlTransaction   trans,   CommandType   cmdType,   String   cmdText,   MySqlParameter[]   cmdParms)   +37 
          DBUtility.ExecuteReader(String   connectionString,   CommandType   cmdType,   String   cmdText,   MySqlParameter[]   commandParameters)   +131 
          LoginDB.GetPasswordByID(String   userID)   +120 
          LoginComponent.LoginJudge(String   userID,   String   password)   +16 
          index.LogButton_Click(Object   sender,   EventArgs   e)   +60 
          System.Web.UI.WebControls.Button.OnClick(EventArgs   e)   +105 
          System.Web.UI.WebControls.Button.RaisePostBackEvent(String   eventArgument)   +107 
          System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String   eventArgument)   +7 
          System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler   sourceControl,   String   eventArgument)   +11 
          System.Web.UI.Page.RaisePostBackEvent(NameValueCollection   postData)   +33 
          System.Web.UI.Page.ProcessRequestMain(Boolean   includeStagesBeforeAsyncPoint,   Boolean   includeStagesAfterAsyncPoint)   +5102 
 请大侠指教 
------解决方案--------------------发布到IIS刚开始也正常 
 可是过了一晚上,就不能登陆 
 ---------- 
 是不是你的连接串信息保存在session中,session过期后,sqlconnection的串找不到引起的
------解决方案--------------------session过期
------解决方案--------------------把Session存到SQL里面吧
------解决方案--------------------mysql中有个设置“Wait timeout”参数用来等待活动连接的超时时间默认是“28800”刚好是8小时,可以把它设成一个比较大的值试试看
------解决方案--------------------注意代码中Connection的关闭。
------解决方案--------------------相不出其他问题