Wednesday, October 1, 2008

Fix: Requested Registry Access is not Allowed in Visual Studio 2008

Yesterday I have installed Silverlight 2 RC0 and Silverlight 2 RC0 tools for Visual Studio 2008 SP1. The installation of the Silverlight 2 tools was successful. After it I have started my visual studio normally and started my project. At this stage one weird thing happened. Visual Studio was unable to render the XAML in design mode. I had checked my whole my code whether there is any error in code which cause error in rendering in visual studio. But when I built it, it was successfully built and run also. Then I tried to find out the actual error. I found that Visual Studio was unable to access some registry key so it was not rendering the XAML because of the user does not have access registry rights. I don't know how these rights removed. It may be a case of removing old version and patching new update to Visual Studio.

Here's the fix for grant access to user for Visual Studio 2008:

Download "subinacl" here. This is a command-line tool that enables administrators to obtain security information about files, registry keys, and services, and transfer this information from user to user, from local or global group to group, and from domain to domain.

After installing subinacl.exe (it will be in the C:\Program Files\Windows Resource Kits\Tools folder.) Now create a BAT file in the same folder say Fix-Visual-Studio-Registry-Access.bat. Now paste the following commands in that bat file.

subinacl /subkeyreg HKEY_LOCAL_MACHINE /grant=administrators=f /grant=system=f subinacl /subkeyreg HKEY_CURRENT_USER /grant=administrators=f /grant=system=f subinacl /subkeyreg HKEY_CLASSES_ROOT /grant=administrators=f /grant=system=f subinacl /subdirectories %SystemDrive% /grant=administrators=f /grant=system=f subinacl /subdirectories %windir%\*.* /grant=administrators=f /grant=system=f

Now you will have questions that what these commands will do. These commands will give administrators and system user of the pc access to HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER, HKEY_CLASSES_ROOT, access to the system drive and access to the windows directory.

Now run your Visual Studio with Administrator Privilege and you will see All Fixed. Now Visual Studio will have permission to the registry and windows directory so it will not raise error "Requested Registry Access is not Allowed."