[英]How to set start parameters and different credentials for multiple instance in windows service installer?
I write a windows service and a installer project using C# with Visual Studio 2010. 我在Visual Studio 2010中使用C#编写了Windows服务和安装程序项目。
This service will get some data from database. 该服务将从数据库中获取一些数据。
There're more than one database with different windows domain login account. 有多个具有不同Windows域登录帐户的数据库。
I want the installer pass the connection string as a parameters to each service instance , each instance has different service name. 我希望安装程序将连接字符串作为参数传递给每个服务实例 ,每个实例具有不同的服务名称。
I look into MSDN and see OnStart(string[] args)
. 我调查了MSDN并看到了
OnStart(string[] args)
。 It needs to write register keys to make a service run with parameters automatically. 它需要写寄存器密钥以使服务自动运行并带有参数。 Is there any other easy ways to do that?
还有其他简便的方法吗?
Beside, I set username and password value to null in my installer project. 此外,我在安装程序项目中将用户名和密码值设置为null。 A dialog will be promoted during the installation.
在安装过程中将弹出一个对话框。 But it's only once.
但是只有一次。 I want to set different credentials for each service instance.
我想为每个服务实例设置不同的凭据。 So it needs to be promotes many times.
因此需要多次推广。
Thank you. 谢谢。
Rather install as many instances as you require and use the connectionStrings
section in your config file. 而是根据需要安装尽可能多的实例,并在配置文件中使用
connectionStrings
部分。
I have a generic host (see: http://shuttle.codeplex.com/SourceControl/changeset/view/ba9750ca1f7a#Shuttle.Core%2fsource%2fShuttle.Core.Host%2fHost.cs ) that allows you to easily implement multiple instances of services or run your code as a console application. 我有一个通用主机(请参阅: http : //shuttle.codeplex.com/SourceControl/changeset/view/ba9750ca1f7a#Shuttle.Core%2fsource%2fShuttle.Core.Host%2fHost.cs ),您可以轻松实现多个实例服务或将代码作为控制台应用程序运行。
HTH 高温超导
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.