The registry has similar permissions as a NTFS file system on your hard
disk. PerformanceCounters needs to create a new key in
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services and modify some of the
values in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Perflib\009. You can check the permissions of these keys
using RegEdit and Right-Clicking on the key and selecting "Permissions..."
on the context menu.
On my Win2003 Server box power users do not have access to write to these
keys.
Generally you should create the categories at installation time of your app
and not at runtime. The reason is that the second line in the code example
below will likely throw complaining that the category does not exist.
PerformanceCounterCategory.Create("SomeCategory", "CategoryHelp",
"SomeCounter", "CounterHelp");
PerformanceCounter pc = new PerformanceCounter("SomeCategory",
"SomeCounter", false);
Ryan Byington [MS]
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm --------------------
| Thread-Topic: Exception whille creating custom performance counter
| thread-index: AcQTOK9SX1wjOR16RhK5EVLYxvNr4Q==
| X-Tomcat-NG: microsoft.public.dotnet.framework.performance
| From: =?Utf-8?B?QW5kcmVhcyBSZW1zcGVyZ2Vy?= <AndreasRemsperger@gmx.de>
| Subject: Exception whille creating custom performance counter
| Date: Fri, 26 Mar 2004 05:46:05 -0800
| Lines: 23
| Message-ID: <BD2D2C1A-6E04-4269-A703-FE0172E0E7D8@microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.performance
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.performance:7041
| NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
| X-Tomcat-NG: microsoft.public.dotnet.framework.performance
|
| Hi @all,
when I try to create a cutsom performance counter from my ASP.NET
application I get an exception calling me, that the requested registry
acces is not allowed. ASP.NET process is running as machine account.
Also trying to run some samples from KB, with my local account (Power
User), faile with the same result.
the code, which should be excecuted look like this:
System.Diagnostics.CounterCreationDataCollection objCCDC = new
System.Diagnostics.CounterCreationDataCollection();
// create and add the counter
System.Diagnostics.CounterCreationData objETimeData = new
System.Diagnostics.CounterCreationData();
objETimeData.CounterType = PerformanceCounterType.ElapsedTime;
objETimeData.CounterName = sCounterName;
objCCDC.Add(objETimeData);
// create the category
System.Diagnostics.PerformanceCounterCategory.Create(sCounterCategoryName,
"some help string", objCCDC);
When executing the last line, the exception is thrown.
Any ideas are welcome.
Andy
|