从Windows Service运行SSIS包时出现问题

|| 我创建了一个Windows服务,该服务每五分钟执行一次SSIS包。它工作得很好,但是有些东西使它崩溃了。 每周重新启动服务器,重新启动后,服务将停止运行。 SSIS程序包开始/结束执行的事件仍会出现在事件查看器中,但该程序包无法正常工作。当我手动启动/停止服务时,所有功能再次恢复正常。 我是否错过了我应该对“ 0”做的事情? 我使用Web服务来获取SSIS包的位置。我从下面的代码中删除了大部分内容,但保留了足够的内容以维护我的服务结构。 这是我的代码的要旨:
namespace MyService
{
    partial class MyService : ServiceBase
    {
        private Timer timer;
        private Package pkg;
        bool executing;

        public MyService()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            executing = false;
            TimerCallback callback = new TimerCallback(Init);
            int period = 1000 * 60; //attempt to initialize every minute.
            timer = new Timer(callback, null, 0, period);
        }


        private void Init(object state)
        {
            try
            {
                //Get `timeIntervalMinutes` from Parameters table
                string mySQLStatement = \"...\";
                DataSet ds = mySQLQuery(...);
                int timeIntervalMinutes = Convert.ToInt32(ds.Tables[\"timeIntervalMinutes\"].Rows[0][\"Value\"]);

                //Get `path` from Parameters table
                string mySQLStatement = \"...\";
                DataSet ds = mySQLQuery(...);
                string path = Convert.ToString(ds.Tables[\"path\"].Rows[0][\"Value\"]);

                //Get `path` from Parameters table
                string mySQLStatement = \"...\";
                DataSet ds = mySQLQuery(...);
                string server = Convert.ToString(ds.Tables[\"server\"].Rows[0][\"Value\"]);

                //Load the SSIS Package
                Application app = new Application();
                pkg = app.LoadFromDtsServer(path, server, null);

                //If this line is reached, a connection to MyWS has been made, so switch the timer to run the SSIS package
                timer.Dispose();
                TimerCallback callback = new TimerCallback(OnTimedEvent);
                int period = 1000 * 60 * timeIntervalMinutes;
                timer = new Timer(callback, null, 0, period);
            }
            catch (Exception e)
            {
                return;
            }
        }


        private void OnTimedEvent(object state)
        {
            if (!executing)
            {
                executing = true;
                DTSExecResult pkgResults = pkg.Execute();
                executing = false;
            }
        }

        protected override void OnStop()
        {

        }

        //<MyWS is here>

    }
}
谢谢您的帮助!     
已邀请:
        您的服务或过程可能依赖于另一项服务-例如MSDTC。如果此服务在启动后还没有准备好,您可能会得到意想不到的结果。延迟服务启动或找出依赖项并在服务属性中进行设置     

要回复问题请先登录注册