将参数发送到 Windows 服务安装程序 Visual Studio
我是 C# 新手,刚刚创建了一个在事件日志中写入一些日志的 Windows 服务。为了安装它,我创建了一个 Visual Studio 安装项目,一切正常。
我希望该服务有一个可以在安装时创建的配置文件。所以它在安装时应该接收一些参数,例如: -写入数据库或事件日志 -输入文件夹路径(它使用从中读取数据的输入文件夹) -ETC。
我知道参数是由服务在 OnStart 方法中接收的,我只是不知道如何将参数发送到该方法。
I am new to C# and I just created a Windows Service that writes some logs in the event log. In order to install it I created a Visual Studio Setup Project and it all works.
I would like this service to have a configuration file that may be created when installing it. So it should receive some parameters when being installed, like:
-writes to database or event log
-input folder path (it uses an input folder where it reads data from)
-etc.
I know the parameters are received by the service in the OnStart method, I just don't know how to send the parameters to this method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
沿着 DJ Kraze 的评论。我将使用应用程序配置 http://msdn.microsoft.com/en-us /library/1xtk877y.aspx。然后创建一个安装项目(创建 MSI)以在安装时设置配置参数。 http://raquila.com/software/configure- app-config-application-settings-during-msi-install/
Along the lines of DJ Kraze's comment. I would use an application config http://msdn.microsoft.com/en-us/library/1xtk877y.aspx. Then create a setup project (creates the MSI) to set the configuration parameters at install time. http://raquila.com/software/configure-app-config-application-settings-during-msi-install/