A
Andrew Raastad
I have been attempting to update a Windows Service that was written a couple
years ago (original programmer no longer here). I have been able to get the
project to work perfectly on the development machine, but when I attempted
to run it on the production box... nothing. So, I built a quick little
WinForm app that mimics the code of the Windows Service (debugging services
is a such a pain), but in this case it spits out to the screen process
messages at various points so I can see where it is going fine and where it
"breaks". And it is "breaking", apparently, on reading from the registry.
Code I am using to read the registry value:
Private Function GetRegKey(ByVal Item As String, Optional ByVal NoValRet
As String = "") As String
Dim Result As String = ""
Try
Dim regFolder As String = "Software\MARS\Integrations"
Dim regKey As RegistryKey
WriteEvent("Accessing SubKey value """ & Item & """ within
[HKEY_LOCAL_MACHINE\" & regFolder.ToUpper & "]")
regKey = Registry.LocalMachine.OpenSubKey(regFolder, True)
Result = regKey.GetValue(Item, NoValRet).ToString
Catch ex As Exception
Result = NoValRet
End Try
Return Result
End Function
The above "WriteEvent()" is just for my test app so I can see what it
returned. And when I run the app, it returns "". I fire up RegEdit, go to
the location specified, and there IS a value for each item in there, and I
have also verified that the spelling of those items EXACTLY matches the
values given as the above "Item" method argument. There should be no reason
I am getting a "" returned.
I run this code on my Dev box, I get values. I run it on the production
box, I get "", and both have the EXACT same registry setup and values. The
only difference is my dev box is Win Vista, and the production box is Win
Server 2003. But this shouldn't make a difference, should it? Is there
something wrong with the above code?
-- Andrew
years ago (original programmer no longer here). I have been able to get the
project to work perfectly on the development machine, but when I attempted
to run it on the production box... nothing. So, I built a quick little
WinForm app that mimics the code of the Windows Service (debugging services
is a such a pain), but in this case it spits out to the screen process
messages at various points so I can see where it is going fine and where it
"breaks". And it is "breaking", apparently, on reading from the registry.
Code I am using to read the registry value:
Private Function GetRegKey(ByVal Item As String, Optional ByVal NoValRet
As String = "") As String
Dim Result As String = ""
Try
Dim regFolder As String = "Software\MARS\Integrations"
Dim regKey As RegistryKey
WriteEvent("Accessing SubKey value """ & Item & """ within
[HKEY_LOCAL_MACHINE\" & regFolder.ToUpper & "]")
regKey = Registry.LocalMachine.OpenSubKey(regFolder, True)
Result = regKey.GetValue(Item, NoValRet).ToString
Catch ex As Exception
Result = NoValRet
End Try
Return Result
End Function
The above "WriteEvent()" is just for my test app so I can see what it
returned. And when I run the app, it returns "". I fire up RegEdit, go to
the location specified, and there IS a value for each item in there, and I
have also verified that the spelling of those items EXACTLY matches the
values given as the above "Item" method argument. There should be no reason
I am getting a "" returned.
I run this code on my Dev box, I get values. I run it on the production
box, I get "", and both have the EXACT same registry setup and values. The
only difference is my dev box is Win Vista, and the production box is Win
Server 2003. But this shouldn't make a difference, should it? Is there
something wrong with the above code?
-- Andrew