Performance Counters - Performance Category creation error
===

I am getting an error when I try to create a new Performance Category from my ASP.NET application. Initially I had some registry related issues but they were solved by giving the user some permissions over some registry keys and adding it to the "Performance Log Users" and "Performance Monitor Users" groups. But now I am getting an exception and I don't know what else to try.

The error happens when I execute this line:

PerformanceCounterCategory.Create(testName, testDescription, PerformanceCounterCategoryType.Unknown, counters);

testName and testDescriptions are string variables that contains name and description of the category and counters is a CounterCreationDataCollection
with 3 counters.


Here is the stack trace of the exception:

   at System.Diagnostics.PerformanceCounterLib.RegisterFiles(String arg0, Boolean unregister)
   at System.Diagnostics.PerformanceCounterLib.RegisterCategory(String categoryName, PerformanceCounterCategoryType categoryType, String categoryHelp, CounterCreationDataCollection creationData)
   at System.Diagnostics.PerformanceCounterCategory.Create(String categoryName, String categoryHelp, PerformanceCounterCategoryType categoryType, CounterCreationDataCollection counterData)
   at CL.Libraries.PerformanceTestUtils.InitializeCounters(List`1 usedCounters, String testName, String testDescription) in C:\CL.Libraries\PerformanceTestUtils.cs:line 104
   

It seems I cannot post an image so here's what I get:

"
UnauthorizedAccessException was caught:

Cannot create or delete the Performance Category 'C:\TEMP\tmpD5E8.tmp' because access is denied.
"


The category key is created in the registry. The file referred above is created and then deleted. I gave the user explicit access to the Temp folder but that didn't help either.

Any help is greatly appreciated.