|
-
Apr 5th, 2018, 03:06 PM
#1
[RESOLVED] Registry.LocalMachine.OpenSubKey returns Nothing
I have an old, and small application with ~250 lines of code. The .NET framework is 2.0. I want to upgrade to newest .NET framework. Since the app is so small, I thought I will create a new app with the same name, select latest framework, and copied & pasted the code from old app to new with .NET Framework 4.5
The problem is that opening a registry key returns "Nothing"
Code:
Dim SoftwareKey As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products"
Using rk As RegistryKey = Registry.LocalMachine.OpenSubKey(SoftwareKey)
The exact same code runs fine in the old app with .NET Framework 2.0, but this returns "Nothing" in the new app with .NET Framework 4.5 selected.
Why something so simple is not working?
-
Apr 5th, 2018, 03:24 PM
#2
Re: Registry.LocalMachine.OpenSubKey returns Nothing
What about just taking a copy of the original app, and simply changing the Target Framework? I've done that before to upgrade components from older FW versions.
-tg
-
Apr 5th, 2018, 05:15 PM
#3
Re: Registry.LocalMachine.OpenSubKey returns Nothing
Wouldn't the S-1-5-18 bit after UserData be some kind of very specific ID for a user?
Something's changed, it's just hard to see what. When you say the old and new apps are working, are they working on the same or on different machines?
This answer is wrong. You should be using TableAdapter and Dictionaries instead.
-
Apr 5th, 2018, 05:20 PM
#4
Re: Registry.LocalMachine.OpenSubKey returns Nothing
Also: get to debugging. The registry is a decrepit old thing and ever since virtualization was introduced there are a lot of little things that can go wrong.
Can you open "Installer"? What about "UserData"? What about "S-1-5-18"? What about "Products"? Trying them one at a time will likely reveal "yes" to some and "no" to others. That gives you some information. Or it'll be "no" to all. That's more information.
The API returns "Nothing" when it thinks you tried to open something that's not there. So be meticulous. Stop asking for exactly the thing you want and start asking for things you're definitely certain are there. If those don't work, we know the problem's likely in how OpenSubkey() is being used.
You've only showed us 2 lines. Are those the only relevant ones? Maybe not. Perhaps if we saw more code we could find some other cause. I'm assuming you verified the Nothing via debugger? If so, maybe these are the most relevant lines. Hard to tell.
This answer is wrong. You should be using TableAdapter and Dictionaries instead.
-
Apr 6th, 2018, 09:15 AM
#5
Re: Registry.LocalMachine.OpenSubKey returns Nothing
 Originally Posted by techgnome
What about just taking a copy of the original app, and simply changing the Target Framework? I've done that before to upgrade components from older FW versions.
-tg
I'm getting old, I cant figure out the simple things now 
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|