Windows服务写入事件日志

时间:2015-02-21 17:27:42

标签: vb.net

在我的应用程序中有奇怪的代码行为。我根据MSDN默认指令创建了Windows服务:https://msdn.microsoft.com/en-us/library/zt39148a%28v=vs.110%29.aspx

正常工作并记录到事件日志。之后我复制了那个项目并在此基础上开始创建第二个几乎相似的项目。我的问题是在代码属于ProjectInstaller.vb的下面部分,当我安装它并尝试启动我得到消息,Windows服务启动并停止imedietly。

Imports System.ComponentModel
Imports System.Configuration.Install

Public Class ProjectInstaller

    Public Sub New()
        MyBase.New()

        'This call is required by the Component Designer.
        InitializeComponent()

        'Add initialization code after the call to InitializeComponent

    End Sub

    Protected Overrides Sub OnBeforeInstall(ByVal savedState As IDictionary)
        Dim parameter As String = "MySvcDeon2"" ""MyLogFileSvcDeon2"
        Context.Parameters("assemblypath") = """" + Context.Parameters("assemblypath") + """ """ + parameter + """"
        MyBase.OnBeforeInstall(savedState)
    End Sub

End Class

在这一行中:

Dim parameter As String = "MySvcDeon2"" ""MyLogFileSvcDeon2"

当我将其更改为此表格时,服务正确启动,没有任何错误用法:

Dim parameter As String = "MySvcDeon1"" ""MyLogFileSvcDeon1"

它的工作。但是Deon2已经由我的第一个Windows服务创建了。怎么了?

0 个答案:

没有答案
相关问题