c# - Reading w3wp .Net Performance Counter Instances programmatically -
when viewing .net performance counters using performance tool can see web process performance counters listed (w3wp, w3wp#1):
however when run following code administrator:
var instancenames = new performancecountercategory(".net clr memory") .getinstancenames() .orderby(x => x); foreach (var name in instancenames) { console.writeline(name); }
this output see:
notice w3wp counters not listed. know why case , how can fix it?
the solution have run application in same bitness website. website 64 bit needed run console application in 64 bit mode. right click on console application project, click properties in build tab untick box says "prefer 32-bit".
also when collect process id w3wp process using process id counter inside .net clr memory category 0 begin with. process id have initialize web site , make sure @ least 1 garbage collection happens. in test code call gc.collect
in application_start
handler.
Comments
Post a Comment