WCF 作为服务:修改 app.config 文件
我有一个作为 Windows 服务运行的 WCF。我将它部署到服务器上(在用头敲击键盘之后)。
上一期:当修改app.config(程序文件下service目录下的programname.exe.config)时,显然需要重新启动。
问题是这样的——当我更改配置文件并尝试重新启动服务时,它会显示“某些服务如果没有工作要做,就会自动停止,例如......”。我必须完全卸载该服务,重新安装,修改配置文件,然后启动该服务。
这似乎非常乏味且不必要。我想我应该能够简单地编辑配置文件并重新启动。是否存在我应该注意的已知冲突或环境?
谢谢! -杰森
I have a WCF running as a Windows service. I deployed it to a server (after quite a bit of banging my head against the keyboard).
Last issue: When making changes to the app.config (programname.exe.config in the service directory under program files), it obviously needs to be restarted.
Problem is this -- when I make a change to the config file and try to restart the service, it gives me the "Some services stop automatically if they have no work to do, for example...". I have to completely uninstall the service, re-install again, modify the config file, and THEN start the service.
This seems incredibly tedious and unnecessary. I think I should be able to simply edit the config file and restart. Is there a known conflict or setting I should be looking out for?
Thanks!
-Jason
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你可以试试这个。
You could try this instead.
只需从您的 msi 中引入一个自定义操作 dll 挂钩即可。
DLL 中的代码(例如修改文件)将在文件复制到磁盘之后但在安装完成之前(即在任何服务启动之前)执行。
Just introduce a custom action dll hook into it from your msi.
The code in the dll (mangling a file for example) will get executed after the files have been copied yo disk but before the setup completes, i.e. before any service gets started.
如果它是 Windows 服务,您必须安装一个新副本(在卸载前一个之后)。
对于通过 IIS 发布的 WCF 服务,您可以在服务中进行更改,构建项目,然后发布它。如果某些其他应用程序已经在使用您的 wcf 服务(端点),则该应用程序中不需要进行任何更改,并且新应用程序可以使用新更改的服务,而不会影响以前的应用程序。
If it's a windows service you have to Install a fresh copy (after uninstalling previous one).
I case of WCF services published over IIS you can make changes in the service build the project and then publish it. If some other application is already using your wcf services (endPoint) then no change is needed in that application and the new changed services can be consumed by new application without affection previous application.