以前做的程序都能运行,昨天将卡巴斯基个人版5换成了6,再运行有数据库连接的程序时就出现下面的问题,是不是安全问题啊,我把卡巴斯基关了,还是不行,高手分析下是什么原因啊?行 35:  SqlConnection con=new SqlConnection(strconn);
行 36:  SqlCommand cmd=new SqlCommand("select newsTypeName from newsType where newsTypeID='"+this.newTypeID+"'",con);
行 37:  con.Open();//错误标记就是在这里
行 38:  string newTypeName=Convert.ToString(cmd.ExecuteScalar());
行 39:  this.Label1.Text=newTypeName;堆栈跟踪: 
[NullReferenceException: 未将对象引用设置到对象的实例。]
   LoadLibraryW(UInt16* ) +0
   System.EnterpriseServices.Thunk.Security.Init() +76
   System.EnterpriseServices.Thunk.Security.SuspendImpersonation() +81
   System.EnterpriseServices.Platform.Initialize() +503
   System.EnterpriseServices.ResourcePool..ctor(TransactionEndDelegate cb) +11
   System.Data.SqlClient.ConnectionPool..ctor(DefaultPoolControl ctrl) +797
   System.Data.SqlClient.PoolManager.FindOrCreatePool(DefaultPoolControl ctrl) +170
   System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +358
   System.Data.SqlClient.SqlConnection.Open() +384
   DormMangement.newscontrol.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\dormmangement\newscontrol.ascx.cs:37
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Control.LoadRecursive() +98
   System.Web.UI.Control.LoadRecursive() +98
   System.Web.UI.Page.ProcessRequestMain() +731 

解决方案 »

  1.   

    数据库连接出错
    有没启动SQL服务器
      

  2.   

    c:\inetpub\wwwroot\dormmangement\newscontrol.ascx.cs:37你所帖的代码,是这个文件吗?
      

  3.   

    看不明白。我使用 asp.net 2.0,你的那个太老了。你试试把你的 .net framework 1.1 或者 1.0 重新安装一遍。
      

  4.   

    我的SQL服务器肯定是开了啊,所帖的代码就是这个用户控件的代码c:\inetpub\wwwroot\dormmangement\newscontrol.ascx.cs:37
    我以前都运行出来了,昨天再运行的时候就不行了啊,现在又可以了,真搞不懂是什么原因啊?
    大家都用是VS03还是VS05啊,以前用05运行的太慢了,而且不稳定,老师建议我们用03的,就用03的了速度蛮快的。
      

  5.   

    需要打NET FRAMEEWORK1.1 SP1的补丁,到微软官方网站下载安装后就好了。
    参考:http://www.orpai.cn/bbs/showtopic-195.aspx