安装Windows服务出现错误
我在本地 PC 上创建了一个简单的 Windows 服务,并向其中添加了以下代码
Protected Overrides Sub OnStart(ByVal args() As String)
Const iTIME_INTERVAL As Integer = 60000 ' 60 seconds.
Dim oTimer As System.Threading.Timer
System.IO.File.AppendAllText("C:\AuthorLog.txt", _
"AuthorLogService has been started at " & Now.ToString())
Dim tDelegate As Threading.TimerCallback = AddressOf EventAction
oTimer = New System.Threading.Timer(tDelegate, Me, 0, iTIME_INTERVAL)
End Sub
Protected Overrides Sub OnStop()
End Sub
Public Sub EventAction(ByVal sender As Object)
System.IO.File.AppendAllText("C:\AuthorLog.txt", _
"AuthorLogService fires EventAction at " & Now.ToString())
End Sub
接下来,我向该解决方案添加了一个安装项目,并添加了一个自定义操作(通过双击应用程序文件夹,然后单击“添加输出文件夹”,然后从对话框中选择主要输出) 。该解决方案构建得很好,但我有两个问题。
1) 每次安装服务时,它都会要求我输入用户名、密码和确认密码;我想知道至少在本地运行时是否有办法摆脱它。我尝试将帐户类型设置为用户、本地服务、本地系统等,但它不断弹出。
2) 输入凭据(随机凭据)后,我收到错误“帐户名称和安全 ID 之间未完成映射”。
请帮助我
I created a simple windows service on my local PC and added the following code to it
Protected Overrides Sub OnStart(ByVal args() As String)
Const iTIME_INTERVAL As Integer = 60000 ' 60 seconds.
Dim oTimer As System.Threading.Timer
System.IO.File.AppendAllText("C:\AuthorLog.txt", _
"AuthorLogService has been started at " & Now.ToString())
Dim tDelegate As Threading.TimerCallback = AddressOf EventAction
oTimer = New System.Threading.Timer(tDelegate, Me, 0, iTIME_INTERVAL)
End Sub
Protected Overrides Sub OnStop()
End Sub
Public Sub EventAction(ByVal sender As Object)
System.IO.File.AppendAllText("C:\AuthorLog.txt", _
"AuthorLogService fires EventAction at " & Now.ToString())
End Sub
Next I added a Setup project to this solution and added a custom action (By double clicking application folder then clicking add output folder then selecting primary output from the dialog). The solution builds fine but I have 2 problems.
1) Everytime I install the service, it asks me for the username, password and confirm password; I was wondering if there was anyway to get rid of it atleast while running locally. I tried setting the account type to user, local service, local system etc but it keeps popping up.
2) Once I enter the credentials (random ones), I get an error "No mapping between account names and security ids was done".
Kindly help me out
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1:您可以按照 此 codeproject 文章中的方式自行安装服务,然后只需将您要使用的用户名/密码发送到
ServiceProcessInstaller
即可。2:尝试以不同的格式输入凭据。如果您当前使用“.\user”,请尝试编写“computer\user”,反之亦然。
1: You could make your service be selfinstalling as in this codeproject article and then just send in the username/password you want to use to the
ServiceProcessInstaller
.2: Try entering the credentials in a different format. If you're currently using ".\user" try writing "computer\user" or vice versa.