配置Windows服务 - 如何以及在哪里存储配置 [英] Configurable Windows Service - How and where to store configuration

查看:181
本文介绍了配置Windows服务 - 如何以及在哪里存储配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个C#应用程序来管理的ERP和客户关系管理之间的数据同步。此应用程序读取表每500毫秒,并通过WebService的将数据发送到客户关系管理。 就目前而言,我有两个屏幕为我的应用:第一个配置的连接(ERP的数据库连接信息和客户关系管理的URL和WS令牌),第二个有一个启动按钮,启动循环线程。

我想知道我的应用程序比Windows服务的安装程序罢了。我想要做的就是启动我的应用程序,配置ERP和CRM连接,然后点击一个安装按钮。当点击这个按钮,服务创建,使相同的工作,我的应用程序现在使当我点击开始按钮。

我已经读过这些链接转换我的应用程序在Windows服务,的制作与贵现有的EXE为当然的并=http://msdn.microsoft.com/en-us/library/d56de412%28v = VS.100%29.aspx相对=nofollow> http://msdn.microsoft.com/en-us/library/d56de412%28v=vs.100%29.aspx

下面是我的问题:

如何使一个可配置的窗口服务?我认为,最简单的方法是将存储配置到文件的公用事业和服务也有同感。在哪里存储这些文件?该实用程序必须能够在事后找到这些文件:注册表?

谢谢

解决方案

这是在.NET存储在此的 Environment.SpecialFolder.ApplicationData <相对路径/ P>

I created a C# application to manage data synchronization between an ERP and a CRM. This application reads a table every 500ms, and sends data via WebService to CRM. For the moment, I have two screens for my application : a first to configure connections (ERP's DB connection informations and CRM's URL and WS Token), a second with a start button to launch the loop thread.

I know want my application to be nothing more than a windows service installer. What I want to do is to launch my application, configure ERP and CRM connections, and then click on a 'Install' button. When this button is clicked, a service is created and makes the same work that my application makes now when i click the 'start' button.

I already read those links Converting my application in a Windows Service, Making an existing exe with gui into windows service and of course http://msdn.microsoft.com/en-us/library/d56de412%28v=vs.100%29.aspx.

Here is my question :

How to make a configurable windows service ? I think the simplest way is to store configuration into files that utility and service would share. Where to store those files ? The utility must be able to find these files afterwards : registry ?

Thanks,

解决方案

It's a common practice in .NET to store application's or service's settings in this relative path Environment.SpecialFolder.ApplicationData

这篇关于配置Windows服务 - 如何以及在哪里存储配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆