Access to the registry key 'Global' is denied

D

Dylan Parry

Hi folks,

I've just got a new machine at work, so I've spent all day copying
across all of my work from my old machine. Now I've come across a
problem that I've never seen before.

I now get the following error when I attempt to run one of my sites:

"Access to the registry key 'Global' is denied"

Here's the stack trace for the error:

--- start ---
[UnauthorizedAccessException: Access to the registry key 'Global' is
denied.]
Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
+2116659
Microsoft.Win32.RegistryKey.InternalGetValue(String name, Object
defaultValue, Boolean doNotExpand, Boolean checkSecurity) +2779573
Microsoft.Win32.RegistryKey.GetValue(String name) +29
System.Diagnostics.PerformanceMonitor.GetData(String item) +96
System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String
item) +147
System.Diagnostics.PerformanceCounterLib.get_CategoryTable() +82
System.Diagnostics.PerformanceCounterLib.CounterExists(String
category, String counter, Boolean& categoryExists) +24
System.Diagnostics.PerformanceCounterLib.CounterExists(String
machine, String category, String counter) +90
System.Diagnostics.PerformanceCounter.Initialize() +720
System.Diagnostics.PerformanceCounter..ctor(String categoryName,
String counterName, String instanceName, Boolean readOnly) +110
System.Diagnostics.PerformanceCounter..ctor(String categoryName,
String counterName) +16
Opus2.Page.Admin.Page_Load(Object sender, EventArgs e) +37314
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object
o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object
sender, EventArgs e) +34
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+1061
---- end ----

I know what code is causing the problem, but I also know that it runs
fine on both my old machine and the live server where the same site is
running.

Have I missed something out when I set up the new machine, or is there
something I can do to allow ASP.NET access to the registry key it's
complaining about?

Cheers,
 
N

Nicholas Paldino [.NET/C# MVP]

Dylan,

What is the account that ASP.NET is configured to run under? AFAIK, the
ASPNET local user doesn't have rights to access the registry by default.
 
U

usenet

Nicholas Paldino [.NET/C# MVP] wrote:

(OT: For some obscure reason I am unable to post to this group through
News.Individual.Net when I'm in the office. I can get headers, but not
post. Other groups are fine, and it works at home... Hence I'm using GG
for this reply)
What is the account that ASP.NET is configured to run under? AFAIK, the
ASPNET local user doesn't have rights to access the registry by default.

Yes, it's running under ASPNET, but then it was running under that same

user (without any extra privileges) on the live server and on my old
machine. I don't pretend to know enough to start fiddling with user
permissions for things like ASP.NET :s

The actual code that is causing the problem, and the lines I have
commented out temporarily to get the system up and running, are:

PerformanceCounter pc = new PerformanceCounter("System", "System Up

Time");
pc.NextValue();
TimeSpan ts = TimeSpan.FromSeconds(pc.NextValue());

I'm presuming that it's the first line causing the problem as that one
is getting a value from the registry?
 
P

Paul

This has reminded me of a very similar issue I once had, same symptons just
a different area of functionality. I had written a web based dotnet
application that would log any errors in the event log. On my PC
everything ran without fail every time, however on the production server it
would fail trying to write to the registry at what appeared to be random
intervals. I started off really confused because I wasn't knowingly writing
to the registry. Similar to you, all user accounts were identical, only
difference appeared to be the two machines I was running it on. Turns out
that the crashes were caused by the production code attempting to log an
error with the event log. The "source" of events are stored in the
registry, if you try to use a "source" that has not yet been setup, then it
attempts to write that new "source" to the registry - which will fail
because the APSNET user doesn't have those rights. The difference in my
case, turns out that I'd developed the logging component in a windows
console, therefore using my NT account details, which had rights to update
the registry with the new "Source". Then on my box, when ever the web based
application wanted to log an error, it could quite happily use the existing
"source".

To get around the issue there was some sort of customer action that I had to
set up as part of the install process (i.e. under a proper NT account,
rather than the ASPNET user). I'm guessing the performance counter
parameters may also be stored in the registry in a similar fashion.

- Paul.


Nicholas Paldino [.NET/C# MVP] wrote:

(OT: For some obscure reason I am unable to post to this group through
News.Individual.Net when I'm in the office. I can get headers, but not
post. Other groups are fine, and it works at home... Hence I'm using GG
for this reply)
What is the account that ASP.NET is configured to run under? AFAIK, the
ASPNET local user doesn't have rights to access the registry by default.

Yes, it's running under ASPNET, but then it was running under that same

user (without any extra privileges) on the live server and on my old
machine. I don't pretend to know enough to start fiddling with user
permissions for things like ASP.NET :s

The actual code that is causing the problem, and the lines I have
commented out temporarily to get the system up and running, are:

PerformanceCounter pc = new PerformanceCounter("System", "System Up

Time");
pc.NextValue();
TimeSpan ts = TimeSpan.FromSeconds(pc.NextValue());

I'm presuming that it's the first line causing the problem as that one
is getting a value from the registry?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top