У меня есть стандартный проект установки Visual Studio, который я преобразовываю в проект InstallShield LE.
У меня есть следующие пользовательские действия в CustomActions-Install-PrimaryOutputFromMyProject (Active) - CustomActionData - / sectionName = "userSettings / SSE.My.MySettings" / provName = "DPAPIProtection"
Как воссоздать это настраиваемое действие в InstallShield?
Вот код в моем классе установщика, все, что он делает, это защищает некоторые разделы файла app.config:
Imports System.ComponentModel
Imports System.Configuration.Install
Imports System.Configuration
'// This file encrypts the app.config file
Public Class CustomInstaller
Inherits Installer
Public Sub New()
MyBase.New()
'This call is required by the Component Designer.
InitializeComponent()
'Add initialization code after the call to InitializeComponent
End Sub
Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
MyBase.Install(stateSaver)
'get Configuration section
'name from custom action parameter
Dim sectionName As String = Me.Context.Parameters("sectionName")
'get Protected Configuration Provider
'name from custom action parameter
Dim provName As String = Me.Context.Parameters("provName")
' get the exe path from the default context parameters
Dim exeFilePath As String = Me.Context.Parameters("assemblypath")
'encrypt the configuration section
ProtectSection(sectionName, provName, exeFilePath)
End Sub
Private Sub ProtectSection(ByVal sectionName As String, ByVal provName As String, ByVal exeFilePath As String)
Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(exeFilePath)
Dim section As ConfigurationSection = config.GetSection(sectionName)
If Not section.SectionInformation.IsProtected Then
'Protecting the specified section with the specified provider
section.SectionInformation.ProtectSection(provName)
End If
section.SectionInformation.ForceSave = True
config.Save(ConfigurationSaveMode.Modified)
End Sub
End Class