ASP.NET Performance counter gives: "Access to the registry key 'Global' is denied"

avvweb used Ask the Experts™
Hello I'm writing a page to get the processor usage. Locally it runs fine but in the server I get a "Access to the registry key 'Global' is denied" error. This is my code:

        Dim oPerf As New PerformanceCounter
        Dim suma As Double = 0
        Dim elementos As Integer = 0
        oPerf.CategoryName = "Processor"
        oPerf.CounterName = "% Processor Time"
        oPerf.InstanceName = "_Total"
        For i = 0 To 100
            suma += oPerf.NextValue
            elementos += 1
        lblValor.Text = suma / elementos

Open in new window

Any help would be much appreciated.

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

If it were my server, I'd block your access to the registry also.  And if you are on shared hosting, I can pretty much guarantee that they will block your access.
Top Expert 2011


What is the application pool identity user for your website? Please make sure that it is set to use network service identity and try again.

If still no luck, you may need to check which registry key your website is looking for using with process monitor and need to give read access. However it is not advisable on the production environment.

Sanjay Santoki
Solved, adding the Application Pool User to the Performance Monitor Users group and setting "Load User Profile" on the IIS site to True.

Thanks anyway!


It worked

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial