性能监视器 .NET CLR Networking 4.0.0.0 实例命名

发布于 2024-12-23 01:49:06 字数 890 浏览 5 评论 0 原文

我正在尝试使用性能计数器来确定我的应用程序已发送或接收的字节数。我按照此处找到的建议解决方案进行操作:计算带宽,但我的应用程序的实例没有显示在“.NET CLR 网络”类别。异常消息:

“指定的实例中不存在“ApplicationName[8824]” 类别”

(我在 App.config 中添加了 ,但在一些网络活动后仍然找不到)

所以我启动了性能监视器,所以看到了错误正如我所料,我的应用程序没有出现在.NET CLR Networking类别中,但幸运的是它可以在.NET CLR Networking 4.0.0.0中找到。 em>

但是,我的 类别。问题是我无法弄清楚实例名称是如何生成的。这是我在性能监视器中看到的实例名称:ApplicationName.exe_p4952_r15_ad1

到目前为止,我已经弄清楚第一部分必须是。由 ProcessNamePID 组成,但我 不知道最后两个(“r15”“ad1”)来自哪里。

有人知道最后两块可能是什么吗?

一种解决方案是枚举“.NET CLR Networking 4.0.0.0”类别中找到的所有实例并搜索 ApplicationName.exe_PID*,但更愿意直接查找正确的名称(如果可能)。

I'm trying to use a Performance Counter do determine how many bytes my application has sent or received. I followed the suggested solution found here: Calculating Bandwidth, but the instance of my application doesn’t show up in the “.NET CLR Networking” category. Exception message:

"Instance 'ApplicationName[8824]' does not exist in the specified
Category"

(I have added <performanceCounters enabled="true"/> in my App.config and it still it cannot be found after some networking activities)

So I started Performance Monitor so see the error with my own eyes. As expected, my application doesn't show up in the .NET CLR Networking category, but it can luckily be found in the .NET CLR Networking 4.0.0.0 category.

However, my problem is that I cannot figure out how instance name is generated. Here is the name of the instance I see in the Performance Monitor: ApplicationName.exe_p4952_r15_ad1.

So far I have figured out that the first parts must be made of ProcessName and PID, but I
have no clue what the last two ("r15" and "ad1") pieces come from.

Does somebody have a clue what the last two pieces could be?

One solution would be to enumerate all the instances found in the “.NET CLR Networking 4.0.0.0” category and search for ApplicationName.exe_PID*, but would prefer to look for the correct name directly (if possible).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

岛徒 2024-12-30 01:49:06

有关如何构建名称的详细信息,请查看此链接。简而言之,“rXX”是执行代码的公共语言运行时(实例)的运行时 ID。

建立这一新的命名约定是为了在并行场景中(一个进程中有多个 CLR 实例;这是从 .NET 4.0 开始的一项新功能),您实际上可以区分性能计数器。

上面的页面上没有描述“adXX”,但从缩写词来看,我认为它代表应用程序域。该数字可能是 AppDomain.Id应用领域。

Check this link for more information on how the name is built. In short the "rXX" is the runtime ID of the common language runtime (instance) that executes your code.

This new naming convention was established so that in side-by-side scenarios (where you have more than one CLR instance in a process; which is a new feature starting with .NET 4.0) you can actually differentiate the performance counters.

The "adXX" is not described on the page above, but from the acronym I'd suppose it stands for Application Domain. The number could possibly be the AppDomain.Id of the application domain.

物价感观 2024-12-30 01:49:06

请参阅此答案了解如何获取正确的名称。简而言之,使用

var processFileName = Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName);
var instanceName = VersioningHelper.MakeVersionSafeName(processFileName, ResourceScope.Machine, ResourceScope.AppDomain);

See this answer on how to get the correct name. In short, use

var processFileName = Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName);
var instanceName = VersioningHelper.MakeVersionSafeName(processFileName, ResourceScope.Machine, ResourceScope.AppDomain);
忆离笙 2024-12-30 01:49:06

应该是:

string appDomain = AppDomain.CurrentDomain.FriendlyName.ToLower();
string a = VersioningHelper.MakeVersionSafeName(appDomain, ResourceScope.Machine, ResourceScope.AppDomain);

我在编写单元测试时遇到了带有进程名称的版本问题。具有应用程序域的版本适用于测试和应用程序结果与进程名称相同。

It should be:

string appDomain = AppDomain.CurrentDomain.FriendlyName.ToLower();
string a = VersioningHelper.MakeVersionSafeName(appDomain, ResourceScope.Machine, ResourceScope.AppDomain);

I've had problems with version with process name when writing unit tests. Version with app domain works for tests and for applications result was the same as with process name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文