0

我有一个 Windows 服务。在向外部客户端发送肥皂消息之前,它每 18 秒连接并检查一次我的数据库。我已经在我的计算机上成功安装了该服务,但它没有做任何特别的事情,也没有用任何错误填充我的服务器日志。

我怎么知道我哪里出错了?

更新

protected override void OnStart(string[] args)
    {
        timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
        timer.Interval = 15000;
        timer.Enabled = true;
        timer.Start();
        eventLog1.WriteEntry("Windows Service 3 Started");
    }

    protected override void OnStop()
    {
        eventLog1.WriteEntry("Windows Service 3 Stopped");

    }

MyRunAPP()是我通过存储过程连接到数据库的地方。

对我的问题的任何见解都会很棒!

  private void RunApp()
    {

        p.Start();
        string connStr = ConfigurationManager.ConnectionStrings["bbsConnectionString"].ConnectionString;
        try
        {
            SqlConnection Con = new SqlConnection(connStr);
            Con.Open();
            SqlCommand cmd = new SqlCommand("AvailableChanges", Con);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter NewSysChangeVersionParam = new SqlParameter("@NewSysChangeVersion", SqlDbType.Int);
            NewSysChangeVersion.Value = (object)NewSysChangeVersion ?? DBNull.Value;
            NewSysChangeVersion.Direction = ParameterDirection.InputOutput;
            NewSysChangeVersion.SqlDbType = SqlDbType.BigInt;
            SqlDataReader sdr = cmd.ExecuteReader();
            int sdrreader = sdr.FieldCount;
            InventoryPushSubscriptionRecord rec = new InventoryPushSubscriptionRecord();


            while (sdr.Read())
            {

                inrec.InventoryPushSubscriptionId = sdr.GetInt32(0);
                inrec.SysChangeVersion = sdr.IsDBNull(1) ? (long?)null : sdr.GetInt64(1);
                inrec.InvDate = sdr.GetDateTime(2);
                inrec.ResortId = sdr.GetInt32(3);
                inrec.RoomType = sdr.GetString(4);
                inrec.InvCount = sdr.GetInt32(5);
                inrec.ResortName = sdr.GetString(6);


                Int64 NewSysChangeVersion;
                NewSysChangeVersion = Convert.ToInt64(rec.LastSysChangeVersion);
                int ResortId;
                ResortId = inrec.ResortId;
                string RoomType;
                RoomType = inrec.RoomType;
                int avail = inrec.InvCount;
                DateTime frodte = inrec.InvDate;
                DateTime todte = inrec.InvDate;
                int NoofRatePackages = sdrreader;
                Int32 InventoryPushSubscriptionId;
                InventoryPushSubscriptionId = inrec.InventoryPushSubscriptionId;
                Int64 NewLastSysChangeVersion;
                NewLastSysChangeVersion = Convert.ToInt64(inrec.SysChangeVersion);
                if (NewSysChangeVersion != null)
                {
                    sendUpdate(NewSysChangeVersion, ResortId, RoomType, avail, frodte, todte, NoofRatePackages, InventoryPushSubscriptionId, NewLastSysChangeVersion);
                }
            }

            //    sdr.Close();
            //    sdr.Dispose();

        }

        catch (Exception ex)
        {

更新 eventLog1.WriteEntry("exception"); 扔; } }

4

1 回答 1

0

按照建议编辑了我的例外。

捕捉(异常前){

            eventLog1.WriteEntry(ex.Message);
            eventLog1.WriteEntry(ex.StackTrace);
            throw;

        }
于 2012-04-29T20:26:30.620 回答