1、Timer控件失效的解决
在Windows 服务不引发计时器事件
原因:
我认为windows服务里不能使用System.Windows.Forms的Timer控件,
Windows.Forms 计时器组件用于 Windows.Forms 环境。 WindowsForms 计时器组件不用于服务器环境,所以要使用System.Timer下的控件。

解决方案
这个可以通过修改控件的类型,把所有使用服务器计时器从命名空间 System.Timers 代替 System.Windows.Forms 计时器。注意System.Timers的事件是Elapsed事件

如:
Service1.Designer.cs

 1VS2005开发windows服务的注意事项namespace MyNewService
 2}
Service1.cs
 1VS2005开发windows服务的注意事项using System;
 2VS2005开发windows服务的注意事项using System.Collections.Generic;
 3VS2005开发windows服务的注意事项using System.ComponentModel;
 4VS2005开发windows服务的注意事项using System.Data;
 5VS2005开发windows服务的注意事项using System.Diagnostics;
 6VS2005开发windows服务的注意事项using System.ServiceProcess;
 7VS2005开发windows服务的注意事项using System.Text;
 8VS2005开发windows服务的注意事项
 9VS2005开发windows服务的注意事项namespace MyNewService
10

相关文章: