473,327 Members | 2,112 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,327 software developers and data experts.

Intermittent failure to read registry key in ASP.NET application...

OK, before I start, let me clarify a few things here. This is not the
run of the mill failure to read a registry key while trying to write
to the Event Log.

Here's our setup:

a) IIS 6.0 server w/ SharePoint installed
b) ASP.NET application w/ NTLM authentication running under an account
(application pool) with ADMIN privileges on the local box.
c) We are NOT using impersonation

We have a registry key under HKLM that can be accessed only by the
account that's running the ASP.NET account. However, occasionally we
see a failure that looks as follows:

Unexpected exception Requested registry access is not allowed.
encountered at at Microsoft.Win32.RegistryKey.OpenSubKey(String
name, Boolean
writable)

What's really surprising is that fact that the error is intermittent,
i.e., we do not see that failure all the time. Furthermore, the error
seems go away on its own at times.

Clearly, it's not a question of privilege because our ASP.NET worker
process is running with full Admin rights.

Atul
Nov 18 '05 #1
4 2164
registry access can be flakey, i had an article about this somewhere can't
find it at the moment.

if you really intend to go after this problem you will need to monitor
access per registry key
regmon utility from sysinternals.com comes to mind. absolutely potent stuff
for monitoring all sorts of registry behavior.

so in a nutshell you wire it up to watch your particular key and wait for
the bug to pop. When it pops, catch it, see what regmon says caused the
problem and kill it dead. It's not that easy though, in fact it is down
right nasty to go after reg issues but that is your general direction. Let
me know what you find out.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"akhare1" <ak*****@my-deja.com> wrote in message
news:20**************************@posting.google.c om...
OK, before I start, let me clarify a few things here. This is not the
run of the mill failure to read a registry key while trying to write
to the Event Log.

Here's our setup:

a) IIS 6.0 server w/ SharePoint installed
b) ASP.NET application w/ NTLM authentication running under an account
(application pool) with ADMIN privileges on the local box.
c) We are NOT using impersonation

We have a registry key under HKLM that can be accessed only by the
account that's running the ASP.NET account. However, occasionally we
see a failure that looks as follows:

Unexpected exception Requested registry access is not allowed.
encountered at at Microsoft.Win32.RegistryKey.OpenSubKey(String
name, Boolean
writable)

What's really surprising is that fact that the error is intermittent,
i.e., we do not see that failure all the time. Furthermore, the error
seems go away on its own at times.

Clearly, it's not a question of privilege because our ASP.NET worker
process is running with full Admin rights.

Atul

Nov 18 '05 #2
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message news:<uF**************@tk2msftngp13.phx.gbl>...
registry access can be flakey, i had an article about this somewhere can't
find it at the moment.

if you really intend to go after this problem you will need to monitor
access per registry key
regmon utility from sysinternals.com comes to mind. absolutely potent stuff
for monitoring all sorts of registry behavior.

<snip>
I am curious to know what you mean by flaky registry access. Is this a
documented bug in the Win32 subsystem (I am pretty sure
Registry.OpenKey calls the underlying Win32 API)?

We have run Regmon on the system before, but didn't notice anything,
but we'll leave it running and hope that the failure occurrs. Also,
what's interesting is we have (failure) auditing turned on for the
registry key, but we haven't noticed a single audit entry.

Atul
Nov 18 '05 #3
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message news:<uF**************@tk2msftngp13.phx.gbl>...
registry access can be flakey, i had an article about this somewhere can't
find it at the moment.

if you really intend to go after this problem you will need to monitor
access per registry key
regmon utility from sysinternals.com comes to mind. absolutely potent stuff
for monitoring all sorts of registry behavior.

BTW, thanks for your suggestions. I have examined the code many times
and simply cannot find anything wrong with it. What's even more
interesting is that we read the registry key once and cache it. The
code looks something like this:

//Obtain AppDomain wide lock...
lock(typeof(MyLockObject))
{
if(MyRegValue != null)
{
try
{
//Open registry key, read value and set MyRegValue

}
catch(Exception Ex)
{
//Log details....
}
finally
{
//if(RegistryHandle != null)
//Close Registry Handle...
}
}
}
As you can see we are ensuring that the registry handle is always
closed so that can't be a factor. Also, we obtain an AppDomain wide
lock so multiple threads cannot be the reason either. ASP.NET does
create multiple AppDomains for the same applications to handle
requests if needed, but I don't see how it can possibly influence
reading of the key.

Atul
Nov 18 '05 #4
I've done some research on this but came up empty handed. your code is the
approach i would take as well. I meant flakey as in permissions errors every
now and again like what you are experiencing. I believe this one is at the
limits of my knowledge.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"akhare1" <ak*****@my-deja.com> wrote in message
news:20**************************@posting.google.c om...
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:<uF**************@tk2msftngp13.phx.gbl>...
registry access can be flakey, i had an article about this somewhere
can't
find it at the moment.

if you really intend to go after this problem you will need to monitor
access per registry key
regmon utility from sysinternals.com comes to mind. absolutely potent
stuff
for monitoring all sorts of registry behavior.

BTW, thanks for your suggestions. I have examined the code many times
and simply cannot find anything wrong with it. What's even more
interesting is that we read the registry key once and cache it. The
code looks something like this:

//Obtain AppDomain wide lock...
lock(typeof(MyLockObject))
{
if(MyRegValue != null)
{
try
{
//Open registry key, read value and set MyRegValue

}
catch(Exception Ex)
{
//Log details....
}
finally
{
//if(RegistryHandle != null)
//Close Registry Handle...
}
}
}
As you can see we are ensuring that the registry handle is always
closed so that can't be a factor. Also, we obtain an AppDomain wide
lock so multiple threads cannot be the reason either. ASP.NET does
create multiple AppDomains for the same applications to handle
requests if needed, but I don't see how it can possibly influence
reading of the key.

Atul

Nov 18 '05 #5

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

Similar topics

1
by: bloodhound | last post by:
Hi, Problem with global.asa not firing 100% of the time. This error crops up several times throughout the day but if you wait a while and reload the page (could be 5 mins or an hour) it will...
0
by: Philip | last post by:
Hi, I have a problem with a win 2003 server Standard edition. Sometimes when I'm working in my web application the session hangs (but not the ASP-application). In the application log I find the...
10
by: Robert | last post by:
We have an ASP.NET site that performs a lot of xml serialization. The serialization occurs in the lbolibrary dll. Occasionally we get an .out file produced in the Winnt\temp folder that contains...
4
by: caa | last post by:
We are intermittently getting the infamous Configuration error: "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be...
2
by: pvl | last post by:
Hi We have the following scenario: 1. SQL server 2000 on Windows 2003 Server 2. Web server 1, running web service 1 on Windows 2003 Server 3. Web server 2, running web service 2 on Windows 2000...
3
by: Lee Chapman | last post by:
Hi, I have a problem where my ASP.NET application occasionally generates a MissingFieldException exception. This unexpectedly happened on my development box, and so I was able to extract some...
2
by: Loane Sharp | last post by:
Hi there I'm downloading data from a remote server to my local disk using Stream.Read() and Stream.Write() (as previously suggested by Ken Tucker in this group). By and large the download and...
4
by: H J van Rooyen | last post by:
Hi All, I am writing a polling controller for an RS-485 line that has several addressable devices connected. It is a small access control system. All is well- the code runs for anything from...
0
by: C.W. | last post by:
Hi I have run into a really bizzare problem in that asp.net stops working intermittently - and I can only get it to restart after restarting my computer. My environment is Windows XP Pro SP2,...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.