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,
--
Dylan Parry - http://webpageworkshop.co.uk
A Flower?
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.
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
"Dylan Parry" <use...@dylanparry.com> wrote in message
news:koee8m0...@dylanparry.com...
(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?
--
Dylan Parry - http://electricfreedom.org
A Flower?
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.
<use...@dylanparry.com> wrote in message
news:1153213309....@35g2000cwc.googlegroups.com...