Friday, August 18, 2006 4:30 PM bart

Vista's registry virtualization and Visual Studio 2005 debugging

Today, I'm in the middle of upgrading an existing .NET 1.x application to .NET 2.0 in Visual Studio 2005, running on Vista. Just to set your mind, the application acts as a shell replacement to support a smooth log on to a remote terminal server (or the access the local browser) and can be used in thin client scenarios on Windows 2000 or Windows XP. I'll post some screenshots later on if time permits.

Now to the serious stuff. For a couple of months (since Vista beta 2) now I'm working on Windows Vista on a day-to-day basis. The application writes to the registry in HKEY_LOCAL_MACHINE to store settings (the reason for that is a historical one and has to do with the "shell replacement" character of the application). A piece of code looks as follows:

settings = Registry.LocalMachine.OpenSubKey("SOFTWARE\\BdsSoft\\ThinClient");

and (in case settings appears to be null and the setup wizard pops up the very first time the app is executed)


So, to inspect what happened in the registry, I opened up regedit.exe (of course causing the Vista's User Account Control dialog to pop up with a nice sound) and navigated to the key in question. However, nothing there :-(.

This is what happened: Windows Vista protects applications from writing to HKLM but leaves the illusion the app can just do whatever it wants (as would it be an administrator on the box). For that purpose, Vista virtualizes the registry (as well as parts of the file system, such as Program Files). In my case, the settings ended up in the so-called VirtualStore than can be found through HKEY_USERS, as shown below.

Have fun! | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks

Filed under: , ,


# re: Vista's registry virtualization and Visual Studio 2005 debugging

Wednesday, September 13, 2006 10:01 AM by Brian Binnerup

This is a good post - I have ran into the same problem - but...

How would one solve this - how can you write stuff to registry that is shared by users?



# re: Vista's registry virtualization and Visual Studio 2005 debugging

Wednesday, September 13, 2006 6:44 PM by bart

Hi Brian,

Haven't tried it yet, but looks like you need to elevate your program to "run as administrator". Automatic program elevation can be controlled through the manifest but I didn't have the time yet to investigate it further. I'll try to blog about this somewhere in the near future.