简体   繁体   English

绩效指标未发布

[英]Performance Counters not being released

All: 所有:

I am using some custom Performance Counters that I have created. 我正在使用一些已创建的自定义性能计数器。 These are multi-instance, with a lifetime of "Process". 这些是多实例,生命周期为“ 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. 问题:当我在VS中进行调试时,如果我停止该过程然后再次启动它,则当我的代码尝试创建性能计数器时,我会遇到异常。 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. 一旦收到此错误,似乎只有一种解决方法-我必须关闭并重新启动Visual Studio-好像VS获得了我的Process Lifetime性能计数器的所有权,即使它实际上是由拥有的进程创建的。 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. 我认为您正在与Visual Studio托管过程进行斗争。 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. 它是一个帮助程序.exe承载CLR来改善调试体验,并且在将项目加载到VS时始终运行。 Project + Properties, Debug tab, scroll down, uncheck the "Enable the Visual Studio hosting process" checkbox. 在“项目+属性”的“调试”选项卡上,向下滚动,取消选中“启用Visual Studio托管过程”复选框。

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. 这确实在某种程度上影响了调试会话,最值得注意的是,在程序中由Console.WriteLine()编写的输出不再显示在“输出”窗口中。 Some obscure security options, not at all well documented. 一些模糊的安全选项,根本没有得到很好的记录。 I doubt you'll have a problem. 我怀疑你会有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM