开发者

Performance Counters not being released

开发者 https://www.devze.com 2022-12-19 03:49 出处:网络
All: I am using some custom Performance Counters that I have c开发者_高级运维reated.These are multi-instance, with a lifetime of \"Process\".

All:

I am using some custom Performance Counters that I have c开发者_高级运维reated. These are multi-instance, with a lifetime of "Process".

the problem: When I'm debugging in VS, if I stop the process and then start it again, I get an exception when my code attempts to create my performance counters. The exception indicates that the peformance counters already exist and that I cannot create them until the owning process releases them.

Once I get this error, there seems to be only 1 way out -- I have to close and restart Visual Studio -- it's as though VS gets ownership of my Process Lifetime performance counters even though it was really created by the owned process. Any idea what I can do about this?

BTW: the problem only seems to surface if my code actually writes to a performance counter before it is shut down.


I think you're doing battle with the Visual Studio hosting process. It is a helper .exe that hosts the CLR to improve the debugging experience, it is always running while you've got a project loaded into VS. Project + Properties, Debug tab, scroll down, uncheck the "Enable the Visual Studio hosting process" checkbox.

This does affect the debugging session somewhat, most notable is that the output written by Console.WriteLine() in your program no longer shows up in the Output window. Some obscure security options, not at all well documented. I doubt you'll have a problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号