Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 55609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:24:15+00:00 2026-05-10T17:24:15+00:00

I have a .NET 3.5 web application for which I have implemented a class

  • 0

I have a .NET 3.5 web application for which I have implemented a class called CalculationsCounterManager (code below). This class has some shared/static members that manage the creation and incrementing of two custom performance counters that monitor data calls to a SQL Server database. Execution of these data calls drives the creation of the counters if the don’t exist. Of course, everything works fine through the unit tests that are executed through the nUnit GUI for this class. The counters are created and incremented fine.

However, when the same code executes through the ASPNET worker process, the following error message occurs: ‘Requested registry access is not allowed.’. This error happens on line 44 in the CalculationsCounterManager class when a read is done to check if the counter category already exists.

Does anyone know a way to provide enough priveledges to the worker process account in order to allow it to create the counters in a production environment without opening the server up to security problems?

Namespace eA.Analytics.DataLayer.PerformanceMetrics     ''' <summary>     ''' Manages performance counters for the calculatioins data layer assembly     ''' </summary>     ''' <remarks>GAJ 09/10/08 - Initial coding and testing</remarks>     Public Class CalculationCounterManager          Private Shared _AvgRetrieval As PerformanceCounter         Private Shared _TotalRequests As PerformanceCounter         Private Shared _ManagerInitialized As Boolean         Private Shared _SW As Stopwatch          ''' <summary>         ''' Creates/recreates the perf. counters if they don't exist         ''' </summary>         ''' <param name='recreate'></param>         ''' <remarks></remarks>         Public Shared Sub SetupCalculationsCounters(ByVal recreate As Boolean)              If PerformanceCounterCategory.Exists(CollectionSettings.CalculationMetricsCollectionName) = False Or recreate = True Then                  Dim AvgCalcsProductRetrieval As New CounterCreationData(CounterSettings.AvgProductRetrievalTimeCounterName, _                                                                         CounterSettings.AvgProductRetrievalTimeCounterHelp, _                                                                         CounterSettings.AvgProductRetrievalTimeCounterType)                  Dim TotalCalcsProductRetrievalRequests As New CounterCreationData(CounterSettings.TotalRequestsCounterName, _                                                                                   CounterSettings.AvgProductRetrievalTimeCounterHelp, _                                                                                   CounterSettings.TotalRequestsCounterType)                  Dim CounterData As New CounterCreationDataCollection()                  ' Add counters to the collection.                 CounterData.Add(AvgCalcsProductRetrieval)                 CounterData.Add(TotalCalcsProductRetrievalRequests)                  If recreate = True Then                     If PerformanceCounterCategory.Exists(CollectionSettings.CalculationMetricsCollectionName) = True Then                         PerformanceCounterCategory.Delete(CollectionSettings.CalculationMetricsCollectionName)                     End If                 End If                  If PerformanceCounterCategory.Exists(CollectionSettings.CalculationMetricsCollectionName) = False Then                     PerformanceCounterCategory.Create(CollectionSettings.CalculationMetricsCollectionName, CollectionSettings.CalculationMetricsDescription, _                                                   PerformanceCounterCategoryType.SingleInstance, CounterData)                 End If              End If              _AvgRetrieval = New PerformanceCounter(CollectionSettings.CalculationMetricsCollectionName, CounterSettings.AvgProductRetrievalTimeCounterName, False)             _TotalRequests = New PerformanceCounter(CollectionSettings.CalculationMetricsCollectionName, CounterSettings.TotalRequestsCounterName, False)             _ManagerInitialized = True          End Sub          Public Shared ReadOnly Property CategoryName() As String             Get                 Return CollectionSettings.CalculationMetricsCollectionName             End Get         End Property          ''' <summary>         ''' Determines if the performance counters have been initialized         ''' </summary>         ''' <value></value>         ''' <returns></returns>         ''' <remarks></remarks>         Public Shared ReadOnly Property ManagerInitializaed() As Boolean             Get                 Return _ManagerInitialized             End Get         End Property          Public Shared ReadOnly Property AvgRetrieval() As PerformanceCounter             Get                 Return _AvgRetrieval             End Get         End Property          Public Shared ReadOnly Property TotalRequests() As PerformanceCounter             Get                 Return _TotalRequests             End Get         End Property          ''' <summary>         ''' Initializes the Average Retrieval Time counter by starting a stopwatch         ''' </summary>         ''' <remarks></remarks>         Public Shared Sub BeginIncrementAvgRetrieval()              If _SW Is Nothing Then                 _SW = New Stopwatch             End If              _SW.Start()          End Sub          ''' <summary>         ''' Increments the Average Retrieval Time counter by stopping the stopwatch and changing the         ''' raw value of the perf counter.         ''' </summary>         ''' <remarks></remarks>         Public Shared Sub EndIncrementAvgRetrieval(ByVal resetStopwatch As Boolean, ByVal outputToTrace As Boolean)             _SW.Stop()             _AvgRetrieval.RawValue = CLng(_SW.ElapsedMilliseconds)             If outPutToTrace = True Then                 Trace.WriteLine(_AvgRetrieval.NextValue.ToString)             End If             If resetStopwatch = True Then                 _SW.Reset()             End If         End Sub          ''' <summary>         ''' Increments the total requests counter         ''' </summary>         ''' <remarks></remarks>         Public Shared Sub IncrementTotalRequests()             _TotalRequests.IncrementBy(1)         End Sub          Public Shared Sub DeleteAll()             If PerformanceCounterCategory.Exists(CollectionSettings.CalculationMetricsCollectionName) = True Then                 PerformanceCounterCategory.Delete(CollectionSettings.CalculationMetricsCollectionName)             End If         End Sub      End Class End Namespace 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T17:24:16+00:00Added an answer on May 10, 2026 at 5:24 pm

    Yes, it’s not possible. You can’t add privileges to the worker process without opening the server up to potential security / DOS problems in a production environment. An installer (like a MSI) usually runs with elevated permissions, and installs / uninstalls the performance counter categories and counters as well as other locked down objects.

    For example, Windows Installer XML (WiX) has support for Performance Counters…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 58k
  • Answers 58k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Can't you make them friends? Like: template<typename T> class CountedPointer… May 11, 2026 at 8:39 am
  • added an answer It sounds like what you need is two different stylesheets.… May 11, 2026 at 8:39 am
  • added an answer Update: As noted by other answers, this is indeed technically… May 11, 2026 at 8:39 am

Top Members

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.

      Related Questions

      No related questions found