我如何确定一个过程在C#托管? [英] How do I determine if a Process is Managed in C#?
问题描述
搜索将返回此结果的位:的哪些进程正在运行的托管代码和哪个版本?
A bit of searching returns this result: Which processes are running managed code and which version?
不过,我想知道是否有更好的方式则只需遍历虽然加载的模块?这似乎有点古怪,以查找字符串的Mscorwks.dll。阅读虽然MSDN上的 Process类似乎并没有指出一个明显解决方案。
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#托管?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!