大神们,危在旦夕,为什么windows服务,我直接点exe文件会向数据库插入数据,但是我安装的话,什么方法也不执行了

解决方案 »

  1.   

    看看运行windows服务的用户权限
      
    *****************************************************************************
    签名档: http://feiyun0112.cnblogs.com/
      

  2.   


    是system   就是不执行方法,不插数据   直接点exe可以
      

  3.   

    控制面板-管理工具--服务右键对应服务,选属性,设置登录,此用户然后程序connectionstring用user/pasword
      

  4.   

    你确定直接点exe可以启动服务?桌面程序与服务的执行过程是完全不同的,所有服务的启动都需要services.exe的支持安装时你可以利用安装类的提交事件立即启动服务
    protected override void OnCommitted(IDictionary savedState)
     {
                base.OnCommitted(savedState);
                System.Threading.Thread.Sleep(1000);
                ServiceController srvController  = null;
                try
                {
                    //安装后由命令行启动,不需要自启动
                    srvController = new System.ServiceProcess.ServiceController (this.serviceInstaller1.ServiceName);
                    srvController.Start();  //重载方法可以传启动参数
                    //设定10秒超时
                    srvController.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(10));
                }
                catch //(Exception exp)
                {
                      // EventLog.WriteEntry("OnInstallCommitted", exp.Message, EventLogEntryType.Error);
                }
                finally
                {
                          if(srvController  != null) srvController.Close();
                }
    }
      

  5.   


     
    神,然后程序connectionstring用user/pasword  这个不懂    用户可以随便设置吗
      

  6.   

    不解  这段代码放到Service1.cs 中还是ProjectInstaller.cs   我不需要cmd执行安装命令了吗。但是我指点点debug的exe   确实插入数据了
      

  7.   

    说了是安装类,自然是放到ProjectInstaller.cs里
      

  8.   

    已经解决,谢谢大家了,是在服务上执行和本地执行,应用程序池的限制不同的问题, 连接数满了,我把using 换成close了,就好了