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):

performance monitor showing w3wp instances

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:

missing w3wp instances

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

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -