如何识别程序集被加载到哪个框架中?

发布于 2024-09-15 11:24:47 字数 514 浏览 4 评论 0原文

一位用户向我们报告,我们的应用程序中的一些奇怪行为可以在安装 .NET 4 后得到解决:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <supportedRuntime version="v2.0.50727" />
  </startup>
</configuration>

我不知道如果您没有指定程序集,它可能会以更高但兼容的版本加载。

是否可以识别可执行文件正在使用哪个框架执行?在运行时?或者通过一些外部过程?我想确认情况确实如此,并且用户体验并不是其他问题造成的。


Process Explorer 说 EVEMon 在 2.0 下运行,我倾向于怀疑问题是环境问题:

Process Explorer

A user reported to us that some strange behaviour in our application can be resolved after installing .NET 4:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <supportedRuntime version="v2.0.50727" />
  </startup>
</configuration>

I wasn't aware that if you didn't specify an assembly it might be loaded in a higher, but compatible version.

Is it possible to identify which framework an executable is executing with? at run-time? or through some external process? I wish to confirm that this is the case, and the users experience has not be the result of some other issue.


Process Explorer says EVEMon is running under the 2.0, I am inclined to suspect the issue is was environmental:

Process Explorer

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

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

发布评论

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

评论(3

愛放△進行李 2024-09-22 11:24:47

在程序集的运行代码中,您可以使用 System.Environment.Version 静态属性来确定它正在执行的 CLR 版本。

如果您不想更改汇编代码,可以使用 Process Explorer 查看运行时进程中加载​​的 DLL。 CLR版本可以通过mscoree.dll的版本来识别。

From within your assembly's running code, you can use the System.Environment.Version static property to determine the CLR version under which it is executing.

If you don't want to change the assembly code, you could use Process Explorer to see the DLLs loaded in the process at runtime. The CLR version can be identified from the version of mscoree.dll.

漆黑的白昼 2024-09-22 11:24:47

没有意义,针对 CLR 版本 2.0.50727 的程序不会自动与 .NET 4.0 一起运行。需要显式 .config 文件条目。考虑到您的客户在 .config 文件方面的能力,这可能是她实际上所做的事情,然后发现有麻烦。

Doesn't make sense, a program that was targeted for CLR version 2.0.50727 won't automatically run with .NET 4.0. An explicit .config file entry is required. Given your client's prowess with .config files, this might be something that she in fact did, then found out there was trouble.

无声静候 2024-09-22 11:24:47

正如 Nicole 所说,Process Explorer 绝对是最简单的方法。您还可以使用 WindDBG 从完整内存转储中获取此信息。

另请注意,在 4.0 中,您可以并排 CLR 托管。在 4.0 之前,如果您不拥有该进程,则您拥有 无法知道加载了什么 CLR。这可能是您出现所描述的行为的原因。

As Nicole said Process Explorer is definitely the easiest way. You can also get this information from a Full Memory Dump using WindDBG.

Also note that with 4.0 you get side by side CLR hosting. Prior to 4.0 if you didn't own the process you had no way of knowing what CLR was loaded. This can be a reason why you experinced the behavior you described.

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