473,395 Members | 1,488 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Unable to delete a registry key from an ASP.NET web service

I’m running an ASP.NET web service which dynamically creates a registry
key, stores some values in it, then, on a subsequent call to another
method in the service, attempts to delete the key. The problem is, the
delete operation always fails with the error message “Cannot write to
the registry key”. The program tries to create the key under
HKEY_CURRENT_USER\some_name\<some GUID value>, but for some reason, it
gets created instead under HKEY_USERS\.DEFAULT\some_name\<some GUID
value>. That doesn’t particularly bother me, though I am curious to
know why the key gets created there instead. But what does bother me is
that the service fails to delete the key and throws an exception. Does
it have anything to do with the stateless nature of the web service, and
that the delete is being attempted on a different thread from the one
that created it? In any case, this statement:

RegistryKey key = RegMainKey.OpenSubKey(guidKey.ToString());

works correctly, but this one:

RegMainKey.DeleteSubKeyTree(guidKey.ToString());

raises the exception. Why? How do I get around it?
Dec 13 '05 #1
2 1638
I wouldn't expect either operation to be successful... I'd assume that
the service runs under the ASPNET user, which shouldn't have
permissions to alter the registry.

(YMMV, I guess)

-j

Dec 13 '05 #2
because asp.net is a service, there is no current user (profile)

-- bruce (sqlwork.com)
"Robert Rotstein" <rr*******@verizon.net> wrote in message
news:gwBnf.1417$1b.55@trndny03...
I’m running an ASP.NET web service which dynamically creates a registry
key, stores some values in it, then, on a subsequent call to another
method in the service, attempts to delete the key. The problem is, the
delete operation always fails with the error message “Cannot write to the
registry key”. The program tries to create the key under
HKEY_CURRENT_USER\some_name\<some GUID value>, but for some reason, it
gets created instead under HKEY_USERS\.DEFAULT\some_name\<some GUID
value>. That doesn’t particularly bother me, though I am curious to know
why the key gets created there instead. But what does bother me is that
the service fails to delete the key and throws an exception. Does it have
anything to do with the stateless nature of the web service, and that the
delete is being attempted on a different thread from the one that created
it? In any case, this statement:

RegistryKey key = RegMainKey.OpenSubKey(guidKey.ToString());

works correctly, but this one:

RegMainKey.DeleteSubKeyTree(guidKey.ToString());

raises the exception. Why? How do I get around it?

Dec 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Peter Gomis | last post by:
I have encountered a situation where I am unable to remove a .NET assembly from the GAC. The message I receive is "Assembly 'assemblyname' could not be uninstalled because it is required by other...
0
by: Maciek | last post by:
Hi When I set Session state mode to StateServer (IIS 6.0; windows2003; .NET 2.0) in my application, I have recived this message:...
10
by: robwharram | last post by:
Hi, I'm quite frustrated in the fact that I can't even display a simple "Hello World" message on .Net. I've been through all of the groups and searched all over the place and haven't been able...
22
by: EP | last post by:
When running my asp.net hosting service (asp.net without IIS), on server 2003 with IIS not installed, I get the following when trying to process a request. "System.DllNotFoundException: Unable to...
0
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in...
2
by: letibal | last post by:
Hello, I have written a windows service and created an installer for it. The service runs under the system accounts. When started, it launches a GUI. By default, the InteractiveProcess property...
1
by: ammar_fake | last post by:
Hello! I have an Oracle linked server connected through MSDAORA. Linked server queries work perfectly - the "openquery" ones as well as the 4-part-named ones. The problem I have is with...
5
by: Ajith Menon | last post by:
I have to install .NET framework 3.0. I already have .NET Framework 1.1 installed on my machine. I don't want to remove framework 1.1 since some of the critical applications are using it. While...
3
by: Peri | last post by:
I can delete RCan't delete Registry.LocalMachine subkeyegistry.LocalMachine subkey using regedit. But not using code: RegistryKey eurotaxKey =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.