Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access denied when trying to read a value from PerformanceCounter

Status
Not open for further replies.

miraclemaker

Programmer
Oct 16, 2002
127
GB
When I try and read a list of available performance counters from PerformanceCounterCategory.GetCategories() I get an 'access denied' error.

I'm very new to this, so please go easy on me.

Here's my code:

Code:
<% @Page Language=&quot;C#&quot; Debug=&quot;true&quot; %>
<% @Import Namespace=&quot;System.Diagnostics&quot; %>
<% @Import Namespace=&quot;System.Collections&quot; %>
<script language=&quot;C#&quot; runat=&quot;server&quot;>
void Page_Load(Object Src, EventArgs E) 
{
  if (!Page.IsPostBack)
  {
      ArrayList arrItems = new ArrayList();
    PerformanceCounterCategory[] arrCategories = 
          PerformanceCounterCategory.GetCategories();
    for (int i=0; i < arrCategories.Length;i++)
      arrItems.Add(arrCategories[i].CategoryName);
    Category.DataSource = arrItems;
    Category.DataBind();    
  }
}
</script>
<html>
<body>
<h3>Dump performance counter categories</h3>
<form runat=&quot;server&quot; method=&quot;post&quot;>
Category:  
<asp:dropdownlist id=&quot;Category&quot; runat=&quot;server&quot;/>
</form>
</body>
</html>

I'm running it on the localmachine, through a webbrowser on the same machine. I'm pretty sure it's something to do with my security policy, but I have security policy for stuff running on the local machine set to trust everything! Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top