windows service 进程正被使用无法复制该文件
我现在在做一个windows service 实现一个合同的指定天数提醒,这个合同在一个用asp.net和c#实现的web网站中。我是通过在windows服务中用一个timer3秒钟去读数据库中设定的时间,如果设定的时间和我现在的时间相等,发通知提醒合同即将到期。
service1.cs中的代码如下:
运行时就是出现如下的错误:无法将文件“obj\x86\Debug\KYPT.exe”复制到“bin\Debug\KYPT.exe”。文件“bin\Debug\KYPT.exe”正由另一进程使用,因此该进程无法访问此文件
我在计算机管理-》服务中把这个服务关掉。提示我需要开启服务。我要是开启服务就会出现上面的错误。但是我的服务时必须要开启的要不让不会定时从数据库中读数据啊 哪位大侠给解决一下!万分感谢!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using Model;
using service;
using System.Data.SqlClient;
namespace KYPT
{
public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
timer1.Interval = 1000;
timer1.Enabled = true;
}
protected override void OnStop()
{
timer1.Enabled = false;
timer1.Stop();
}
private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
timer1.Enabled = false;
InformSrv bs = new InformSrv();
List<InformInfo> listcontact = bs.getremindertime();
listcontact.ForEach(c =>
{
DateTime dt1 = DateTime.Now;
DateTime dt2 = Convert.ToDateTime(c.ProRemindTime);
TimeSpan span = dt1 - dt2;
BaseSrv<InformInfo> inform = new BaseSrv<InformInfo>();
if (span.TotalSeconds == 0)
{
InformInfo inf = new InformInfo();
inf.PTypeName = c.PTypeName;
inf.PType = c.PType;
inf.IsApply = 1;
inform.add(inf);
}
});
timer1.Enabled = true;
}
}
}
相关推荐
Windows 安装IIS出现的问题(无法安装IIS,提示“安装程序无法复制文件IISApp.vbs”)
在重装IIS6.0的时候会遇到“安装程序无法复制文件IISApp.vbs”等一系列错误......
在Service中通过WindowManger添加View的方式来把UI界面显示出来
更多学习和讨论,欢迎加入我们!有许多来自一线的技术大牛,也有在小厂或外包公司奋斗的码农,我们致力打造一个平等,高质量的Android交流圈子,不一定能短期就让每个人的技术突飞猛进,但从长远来说,眼光,格局,长远发展的方向才是最重要的。这里有2000+小伙伴,让你的学习不寂寞~·
安装IIS提示安装程序无法复制文件staxmem.dll处理方法
安装IIS提示安装程序无法复制文件staxmem.dll处理方法
Windows Service Wrapper
使用方法: 1. 下载最新版的 Windows Service Wrapper 程序,比如我下载的名称是 "winsw-1.9-bin.exe", 2. 将重命名后的 myapp.exe 复制到 nginx 的安装目录(我这里是 "D:\server\nginx-1.5.2") 3. 在同一个目录下创建一个Windows Service Wrapper的XML配置文件,名称必须与第一步重命名时使用的名称一致(比如"winsw-1.9-bin.xml") 文件内容如下: nginx nginx nginx D:\server\nginx-1.5.2\nginx.exe D:\server\nginx-1.5.2\ roll -p D:\server\nginx-1.5.2 -p D:\server\nginx-1.5.2 -s stop 4. 命令行下执行以下命令,以便将其安装成Windows服务。 F:\nginx-0.9.4> myapp.exe install OK,至此,完工,确认一下:我的电脑 右键 -> 管理 -> 服务 -> 是否有了个 nginx 呢?启动起来,在浏览器中 访问 http://localhost 确认一下,再 停止服务,再访问一下 http://localhost 确认一下。
win2003 sp2 安装iis提示无法复制文件解决办法[已测]
Windows2003打了SP2补丁再安装IIS提示无法复制文件,或安装了sp2的系统,卸载iis再安装也会提示无法复制文件,或找不到文件。


