• <i id='7IOAp'><tr id='7IOAp'><dt id='7IOAp'><q id='7IOAp'><span id='7IOAp'><b id='7IOAp'><form id='7IOAp'><ins id='7IOAp'></ins><ul id='7IOAp'></ul><sub id='7IOAp'></sub></form><legend id='7IOAp'></legend><bdo id='7IOAp'><pre id='7IOAp'><center id='7IOAp'></center></pre></bdo></b><th id='7IOAp'></th></span></q></dt></tr></i><div id='7IOAp'><tfoot id='7IOAp'></tfoot><dl id='7IOAp'><fieldset id='7IOAp'></fieldset></dl></div>

    <small id='7IOAp'></small><noframes id='7IOAp'>

  • <tfoot id='7IOAp'></tfoot>

        <bdo id='7IOAp'></bdo><ul id='7IOAp'></ul>
    1. <legend id='7IOAp'><style id='7IOAp'><dir id='7IOAp'><q id='7IOAp'></q></dir></style></legend>

        .NET 4.0 &amp; 上的性能计数器Windows 7的

        时间:2023-10-24
        <tfoot id='1Iusa'></tfoot>

          <tbody id='1Iusa'></tbody>
        • <bdo id='1Iusa'></bdo><ul id='1Iusa'></ul>

              <i id='1Iusa'><tr id='1Iusa'><dt id='1Iusa'><q id='1Iusa'><span id='1Iusa'><b id='1Iusa'><form id='1Iusa'><ins id='1Iusa'></ins><ul id='1Iusa'></ul><sub id='1Iusa'></sub></form><legend id='1Iusa'></legend><bdo id='1Iusa'><pre id='1Iusa'><center id='1Iusa'></center></pre></bdo></b><th id='1Iusa'></th></span></q></dt></tr></i><div id='1Iusa'><tfoot id='1Iusa'></tfoot><dl id='1Iusa'><fieldset id='1Iusa'></fieldset></dl></div>

                  <small id='1Iusa'></small><noframes id='1Iusa'>

                  <legend id='1Iusa'><style id='1Iusa'><dir id='1Iusa'><q id='1Iusa'></q></dir></style></legend>
                  本文介绍了.NET 4.0 &amp; 上的性能计数器Windows 7的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个在 VS2008 和 Vista 上运行良好的程序,但我正在 Windows 7 和 VS2010/.NET Framework 4.0 上尝试它,但它不工作.最终的问题是 System.Diagnostics.PerformanceCounterCategory.GetCategories() (和其他 PerformanceCounterCategory 方法)不起作用.我收到 System.InvalidOperationException 消息无法加载计数器名称数据,因为从注册表中读取了无效索引".

                  I have a program that works fine on VS2008 and Vista, but I'm trying it on Windows 7 and VS2010 / .NET Framework 4.0 and it's not working. Ultimately the problem is that System.Diagnostics.PerformanceCounterCategory.GetCategories() (and other PerformanceCounterCategory methods) is not working. I'm getting a System.InvalidOperationException with the message "Cannot load Counter Name data because an invalid index '' was read from the registry."

                  我可以用下面显示的非常简单的程序来重现这个:

                  I can reproduce this with the very simple program shown below:

                  class Program
                  {
                      static void Main(string[] args)
                      {
                          foreach (var pc in System.Diagnostics.PerformanceCounterCategory.GetCategories())
                          {
                              Console.WriteLine(pc.CategoryName);
                          }
                      }
                  }
                  

                  我确实以管理员身份运行该程序.我是否在附加 VS/Debugger 的情况下运行它并不重要.我没有另一台装有 Windows 7 或 VS2010 的机器来测试它,所以我不确定这里的事情(或两者都复杂?).它是 Windows 7 x64,我尝试强制应用在 x32 和 x64 中运行,但得到相同的结果.

                  I did make sure I'm running the program as an admin. It doesn't matter if I run it with VS/Debugger attached or not. I don't have another machine with Windows 7 or VS2010 to test it on, so I'm not sure which is complicating things here (or both?). It is Windows 7 x64 and I've tried forcing the app to run in both x32 and x64 but get the same results.

                  推荐答案

                  我的系统上的性能计数器似乎已损坏.虽然我没有完全关注 这篇文章,它使我找到了解决方案.这是我所做的:

                  It seems performance counters were corrupted on my system. Although I didn't follow this post exactly, it led me to the solution. Here is what I did:

                  在具有管理员/提升权限的命令提示符中键入以下内容:

                  In an command prompt with administrator/elevate privileges typed the following:

                  lodctr /?
                  

                  里面有用的东西……

                  然后输入:

                  lodctr /R
                  

                  根据上一步中的文档,这会让 Windows 根据当前的注册表设置和备份 INI 文件从头开始重建 perf 注册表字符串和信息. 我感觉这就是做了魔术.但是,接下来我注意到 .NET 性能计数器不再存在,因此基于 this 我输入了以下内容来重新加载它们:

                  According to the docs from the prior step, this gets windows to rebuild the perf registry strings and info from scratch based on the current registry settings and backup INI files. I have a feeling this is what did the magic. However, next I noticed the .NET performance counters were not there anymore so based on this I typed the following to reload them:

                  lodctr "C:WindowsMicrosoft.NETFramework64v4.0.20506corperfmonsymbols.ini"
                  

                  请注意,此路径适用于 x64 上的 .NET Framework 4.0.您可以想象框架/平台的其他变体的路径.我猜测您应该始终从已安装的 .NET 框架的最高版本加载计数器,但这只是猜测.

                  Note that this path is for .NET Framework 4.0 on x64. You can imagine the path for other variations of the framework/platform. I'm guessing you should always load the counters from the highest version of the .NET framework that you have installed, but that is just a guess.

                  我希望有一天这对其他人有所帮助!

                  I hope this helps someone else someday!

                  这篇关于.NET 4.0 &amp; 上的性能计数器Windows 7的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何以编程方式将文件夹添加到用户的收藏夹(在 Windows 资源管理器中)? 下一篇:程序兼容性助理认为我的应用是安装程序

                  相关文章

                  1. <tfoot id='SUg6G'></tfoot>
                      <bdo id='SUg6G'></bdo><ul id='SUg6G'></ul>
                    <i id='SUg6G'><tr id='SUg6G'><dt id='SUg6G'><q id='SUg6G'><span id='SUg6G'><b id='SUg6G'><form id='SUg6G'><ins id='SUg6G'></ins><ul id='SUg6G'></ul><sub id='SUg6G'></sub></form><legend id='SUg6G'></legend><bdo id='SUg6G'><pre id='SUg6G'><center id='SUg6G'></center></pre></bdo></b><th id='SUg6G'></th></span></q></dt></tr></i><div id='SUg6G'><tfoot id='SUg6G'></tfoot><dl id='SUg6G'><fieldset id='SUg6G'></fieldset></dl></div>

                      <legend id='SUg6G'><style id='SUg6G'><dir id='SUg6G'><q id='SUg6G'></q></dir></style></legend>

                      <small id='SUg6G'></small><noframes id='SUg6G'>