I am writing a service program and I debugged most of the code fine using
#If DEBUG Then
#Else
but after installing the server and running it I get this error that I get with writing ex.tostring to a text file:
System.NullReferenceException: Object reference not set to an instance of an object. at HimayaService.Himaya.TimerBackup_Tick(Object sender, ElapsedEventArgs e)
so HimayaService is the name of my service, Himaya the name of my class and TimerBackupTick was declared right:
AddHandler TimerBackup.Elapsed, AddressOf TimerBackup_Tick
TimerBackup.Enabled = True
TimerBackup.Interval = 30000`
after trying to find where the error is at it was at the first line in TimerBackup_Tick which is
Dim databasekey3 As RegistryKey = Registry.CurrentUser.OpenSubKey(mainsubkey)
mainsubkey
is an actual subkey that I am sure works fine since it works when debugging with Visual Studio, what might be the problem here as the other Timer's tick events work fine and don't give errors.