日期:2014-05-18  浏览次数:20768 次

安装包问题,安装时怎么替换一个正在运行的Windows Service 的dll
安装包问题,安装时怎么替换一个正在运行的Windows   Service   的dll。
我准备安装的时候,net   stop   servicename
                                    copy   servicename.dll   destination_dir\servicename.dll
                                    net   start   servicename
这些操作在安装的时候,一次性完成。

------解决方案--------------------
放在一个批处理文件.bat里
@echo
net stop servicename
opy servicename.dll destination_dir\servicename.dll
net start servicename

------解决方案--------------------
用批处理也没什么不好的,经济简单。只要调用的时候别显示出那个dos窗口就好。

不过,也可以用ServiceControler 控制服务开启关闭
------解决方案--------------------
你的安装包里自己实现去执行那个bat啊,呵呵,用户根本不知道你是执行了bat文件

或者用Process.Start来调用net 和 copy命令都可以的啊,两个的原理是一样。

最后你也可以用SServiceControl类,来控制,就是多几行代码而已