当前位置: 代码迷 >> C# >> F5运作一点错没有 , .exe打开就有错 ,
  详细解决方案

F5运作一点错没有 , .exe打开就有错 ,

热度:2384   发布时间:2013-02-25 00:00:00.0
F5运行一点错没有 , .exe打开就有错 ,............
************** 异常文本 **************
System.NullReferenceException: 未将对象引用设置到对象的实例
   在 DB.GetSqlCon() 位置 E:\应用\DormManageSystemfinal\app_code\DB.cs:行号 30
   在 DB.GetDataTable(String sql) 位置 E:\应用\DormManageSystemfinal\app_code\DB.cs:行号 73
   在 DormManageSystem.AddStudent.comboBox_lou_SelectedIndexChanged(Object sender, EventArgs e) 位置 E:\应用\DormManageSystemfinal\AddStudent.cs:行号 89
   在 System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)
   在 System.Windows.Forms.ComboBox.WmReflectCommand(Message& m)
   在 System.Windows.Forms.ComboBox.WndProc(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


F5运行一点错没有  , .exe打开就有错 ,啥情况

------解决方案--------------------------------------------------------
行号都告诉你了,那行代码中你访问量null对象
------解决方案--------------------------------------------------------
F5运行的exe和你点的exe是同一个吗?
------解决方案--------------------------------------------------------
删除原exe,重新生成个看看
------解决方案--------------------------------------------------------

------解决方案--------------------------------------------------------
确保exe目录下有你程序名称的config文件?
------解决方案--------------------------------------------------------
引用:
引用:确保exe目录下有你程序名称的config文件?

这有什么关系,没明白.

string ConString = System.Configuration.ConfigurationManager.ConnectionStrings["dormmanageConnectionString"].ConnectionString;//从config文件里取值,没找到config文件当然报错了
  相关解决方案