Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net Windows服务安装项目自定义对话框-如何获取变量?_Vb.net_Visual Studio 2010_Windows Services_Installation_Setup Project - Fatal编程技术网

Vb.net Windows服务安装项目自定义对话框-如何获取变量?

Vb.net Windows服务安装项目自定义对话框-如何获取变量?,vb.net,visual-studio-2010,windows-services,installation,setup-project,Vb.net,Visual Studio 2010,Windows Services,Installation,Setup Project,关于windows服务的快速问题,我为我的windows服务添加了一个安装项目,并在其中添加了一个带有4个文本字段的自定义对话框,但我的问题是如何获取这些信息/变量 我还为windows服务添加了一个安装程序,之后是安装项目,带有自定义对话框 这些信息类似于数据库连接字符串,等等——所以只需要字符串值 这是我的“项目安装程序”代码。如果您想查看,我为windows系列添加的安装程序项 Imports System Imports System.ComponentModel Imports

关于windows服务的快速问题,我为我的windows服务添加了一个安装项目,并在其中添加了一个带有4个文本字段的自定义对话框,但我的问题是如何获取这些信息/变量

我还为windows服务添加了一个安装程序,之后是安装项目,带有自定义对话框

这些信息类似于数据库连接字符串,等等——所以只需要字符串值

这是我的“项目安装程序”代码。如果您想查看,我为windows系列添加的安装程序项

    Imports System
Imports System.ComponentModel
Imports System.Configuration.Install
Imports System.ServiceProcess
Imports System.Runtime.InteropServices



Public Class ProjectInstaller

    Public Sub New()
        MyBase.New()

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

        My.Settings.TestSetting = Context.Parameters.Item("PathValue")

#If DEBUG Then

        Dim ServicesToRun As ServiceBase()
        ServicesToRun = New ServiceBase() {New tdsCheckService()}
        ServiceBase.Run(ServicesToRun)

#Else

        Dim listener As New tdsCheckService()
        listener.Start()

#End If

    End Sub

    Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
        MyBase.Install(stateSaver)
        Dim regsrv As New RegistrationServices
        regsrv.RegisterAssembly(MyBase.GetType().Assembly, AssemblyRegistrationFlags.SetCodeBase)
    End Sub
    Public Overrides Sub Uninstall(ByVal savedState As System.Collections.IDictionary)
        MyBase.Uninstall(savedState)
        Dim regsrv As New RegistrationServices
        regsrv.UnregisterAssembly(MyBase.GetType().Assembly)
    End Sub

    Private Sub ServiceProcessInstaller1_AfterInstall(sender As Object, e As InstallEventArgs) Handles ServiceProcessInstaller1.AfterInstall

    End Sub

    Private Sub ServiceInstaller1_AfterInstall(sender As Object, e As InstallEventArgs) Handles ServiceInstaller1.AfterInstall

    End Sub
End Class

您应该能够使用上下文对象访问它们

 'Get Protected Configuration Provider name from custom action parameter
        Dim variableName As String = Context.Parameters.Item("dialogSettingName")


  Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
    MyBase.Install(stateSaver)

应该有一个安装事件。我们基本上有一个与服务相关联的配置文件。在这里,我们有许多连接字符串。安装后,系统会提示用户输入这些连接字符串。然后我们读取它们,对它们进行加密,然后将它们放回配置文件中。是的,但我有两个“后安装”事件。。我应该使用哪一个?应该有一个可重写的方法。见上图:奇怪-我的代码中没有这个-我可能做错了什么吗?我已经手动创建了这个方法,对吗?我会把代码贴在上面