Кто-нибудь знает способ передачи параметра пространства имен конструктору InstrumentedAttribute в ProjectInstaller или инсталляторе?
Это служба Windows. ProjectInstaller находится ниже, но довольно стандартно.
Я хочу установить NamespaceName-атрибута InstrumentedAttribute в коде после извлечения его из, скажем, файла конфигурации, а не устанавливать его в следующем атрибуте:
<Assembly: Instrumented("Root/EnRoute/Interfaces/Spill")>
Полагаю, мне нужен собственный конструктор InstrumentedAttribute, но я не могу понять, как это сделать.
ProjectInstaller:
Imports System.Management.Instrumentation
<Assembly: Instrumented("Root/EnRoute/Interfaces/Spill")> ', "G:S-1-1-0"
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
Dim managementInst As New ManagementInstaller
Installers.Add(managementInst)
End Sub
''' <summary>
''' add config file name to the registry ImagePath for spill interface(s)
''' that are not the default interface
''' </summary>
''' <param name="stateSaver"></param>
Public Overrides Sub Install(stateSaver As IDictionary)
MyBase.Install(stateSaver)
If Context.Parameters.ContainsKey("configName") Then
' write the config name to include the group name (law, fire, a, b, 1, blah, whatever)
' example: EnRoute.Interface.Spill.<groupname>.Service.exe.config
Dim system = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("System")
Dim currentControlSet = system.OpenSubKey("CurrentControlSet")
Dim services = currentControlSet.OpenSubKey("Services")
Dim service = services.OpenSubKey(Me.ServiceInstaller1.ServiceName, True)
service.SetValue("Description", Me.ServiceInstaller1.ServiceName + " Service")
Dim config = service.CreateSubKey("Parameters")
config.SetValue("Arguments", Command)
Console.WriteLine(service.GetValue("ImagePath"))
service.SetValue("ImagePath", service.GetValue("ImagePath") & " " & Context.Parameters.Item("configName"))
End If
End Sub
Protected Overrides Sub OnBeforeInstall(savedState As IDictionary)
MyBase.OnBeforeInstall(savedState)
Me.ServiceInstaller1.DisplayName = "EnRoute Interface Spill"
Me.ServiceInstaller1.ServiceName = "EnRoute Interface Spill"
End Sub
Protected Overrides Sub OnBeforeUninstall(savedState As IDictionary)
MyBase.OnBeforeUninstall(savedState)
Me.ServiceInstaller1.DisplayName = "EnRoute Interface Spill"
Me.ServiceInstaller1.ServiceName = "EnRoute Interface Spill"
End Sub
End Class