ASP.NET/C# - custom PerformanceCounters only show up in 32-bit perfmon on 64-bit system

I am trying to create a set of custom performance counters that will be used by my ASP.NET application. I am using the following code to increment the counters:

internal static void Increment(String instanceName, DistributedCacheCounterInstanceType counterInstanceType)
{
    var permission = new PerformanceCounterPermission(PerformanceCounterPermissionAccess.Write, Environment.MachineName, "CounterName");
    permission.Assert();

    var counter = new PerformanceCounter("CategoryName", "CounterName", instanceName, false);
    counter.RawValue++; // Use RawValue++ instead of Increment() to avoid locking
    counter.Close();
}

      

This works fine in unit tests as well as in Cassini on my dev box (Vista Business x64). I can observe the counters running in the Performance Monitor. However, the counters don't seem to register increments in my production environment (Win Server 2003 x64). There are counter instances, but they all just show "-" to display the last / average / minimum / maximum value.

Any ideas as to what I might be doing wrong?

EDIT: Here's a (possibly somewhat outdated) MSDN article that I used for reference

EDIT 2: I am using VS 2008 / .NET Framework v3.5 SP1 if that matters.

EDIT 3: Just found this article about 32 bit / 64 bit apps and monitor mismatch , but I donโ€™t know how this applies to my situation, if at all. Cassini is indeed a 32 bit application, but I had no problem with by looking at the values โ€‹โ€‹on my 64-bit system On my production server both the application and the system are 64-bit, but I can't see the values.

EDIT 4: The values โ€‹โ€‹are displayed when I run 32 bit perfmon on the production server. So, I suppose the question now is, why can't I read the values โ€‹โ€‹in 64 bit perfmon?

EDIT 5: This actually works, I just had to restart my perfmon instance because it was open before the counters were created.

+1


source to share


1 answer


I read that creating a PerformanceCounter instance is quite resource intensive. Have you ever wondered how to cache them in the Session / Application variable?

Also, is it advisable to update the counter without blocking in a multithreaded ASP.net application?



Patrick

+1


source







All Articles