问题描述
稍微搜索一下就会返回这个结果:哪些进程正在运行托管代码以及哪个版本?
A bit of searching returns this result: Which processes are running managed code and which version?
但是我想知道是否有更好"的方法然后简单地遍历加载的模块?寻找字符串mscorwks.dll"似乎有点古怪.尽管阅读 MSDN 上的 Process Class 似乎没有指出明显的解决方案.
However I am wondering if there is a 'better' way then simply iterating though the loaded modules? It seems a little quirky to look for the string "mscorwks.dll". Reading though the Process Class on MSDN doesn't seem to point out an obvious solution.
假设
- .NET 4.0
- 我手头有一个流程"
谢谢
推荐答案
对于任何未来的 Google 员工:我最终使用了此处发布的建议答案 如何检查程序是否正在使用 .NET?(感谢 0xA3!)
For any future Googlers: I ended up using the suggested answer posted here How to check if a program is using .NET? (thanks 0xA3!)
Process mProcess = //Get Your Process Here
foreach (ProcessModule pm in mProcess.Modules)
{
if (pm.ModuleName.StartsWith("mscor", StringComparison.InvariantCultureIgnoreCase))
{
return true;
}
}
顺便说一下,我在原始帖子中提到的寻找mscorwks.dll"不适用于 .NET 4.0.
As an aside looking for "mscorwks.dll" as mentioned in my original post does not work for .NET 4.0.
这篇关于如何确定进程是否在 C# 中管理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!