检查运行我的代码需要什么版本的 .NET

发布于 2024-09-17 01:07:21 字数 360 浏览 9 评论 0 原文

我正在用 C# 编写代码库,并且遇到了测试 PC 未安装正确的 .NET 3.5 服务包来运行代码的问题(与此处发生的问题相同:仅在我的计算机上发生异常:未找到方法:WaitHandle.WaitOne(Int32)< /a>)。我想知道是否有一个静态代码分析工具可以在我的代码中运行,它可以告诉我每个单独模块(或程序集)所需的 .NET 最低版本。

谢谢。

I am writing a code base in C#, and have had issues with test PC's not having the correct service pack of .NET 3.5 installed to run the code (the same issue as occuring here: Exception is occuring only on my machine: Method not found: WaitHandle.WaitOne(Int32)). I am wondering if there is a static code analysis tools that I can run across my code that will tell me the minimum version of .NET required by each of the individual modules (or by the assembly).

Thanks.

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

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

发布评论

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

评论(2

第几種人 2024-09-24 01:07:21

项目属性->应用程序->目标框架。

Project properties->Application->Target framework.

提笔书几行 2024-09-24 01:07:21

我不知道有任何静态分析工具,但根据 MSDN 文档和一些博客文章,我发现了以下内容:

  • VS 2008 / VS 2008 SP1+ / VS 2010“.NET Framework 2.0” - .NET 2.0 RTM
  • VS 2008 / VS 2008 SP1+ / VS 2010“.NET Framework 3.0” - .NET 3.0 RTM
  • VS 2008“.NET Framework 3.5” - .NET 3.5 RTM
  • VS 2008 SP1+“.NET Framework 3.5”,引用 System.Data .Entity.dll 或使用 ClickOnce - .NET 3.5 SP1
  • VS 2008 SP1+“.NET Framework 3.5”,而不引用 System.Data.Entity.dll 并且不使用 ClickOnce - .NET 3.5 RTM
  • VS 2010“.NET Framework 3.5”- .NET 3.5 SP1
  • VS 2008 SP1+“.NET Framework 客户端配置文件”- .NET 3.5 SP1(客户端)
  • VS 2010“.NET Framework 3.5 客户端配置文件”- .NET 3.5 SP1(客户端) )
  • VS 2010“.NET Framework 4.0”- .NET 4.0 RTM
  • VS 2010“.NET Framework 4.0 客户端配置文件”- .NET 4.0 RTM(客户端)

注意:

  • VS 2008 附带 .NET 3.5 RTM; VS 2008 SP1 附带 .NET 3.5 SP1; VS 2010 附带 .NET 4.0 RTM。
  • VS 2010 无法针对早期版本,除非单独安装它们。
  • 客户端配置文件是在 .NET 3.5 SP1 中引入的,
  • VS 2010 是第一个具有可扩展多目标的版本(因此理论上,它将能够针对未来的 .NET 版本而无需 VS 更新)。

我相信 .NET 3.5 SP1 是唯一添加了重要功能的服务包,因此它是唯一会导致 MissingMethodException 问题的服务包。例如,这意味着 3.0 RTM、3.0 SP1 和 3.0 SP2 具有相同的公共 API。我还没有找到对此的明确确认,但“.NET 中的新增功能”文档仅涵盖 2.0/3.5/3.5SP1/4.0,因此这是一个合乎逻辑的结论。

VS 2008 SP1 对于“.NET Framework 3.5”有一些奇怪的规则(仅在实际使用时才尝试以 SP1 为目标),但 VS2010 仅支持以 .NET 3.5 SP1 为目标。

来源:

I am not aware of any static analysis tool, but here's what I've found, based on MSDN docs and a few blog posts:

  • VS 2008 / VS 2008 SP1+ / VS 2010 ".NET Framework 2.0" - .NET 2.0 RTM
  • VS 2008 / VS 2008 SP1+ / VS 2010 ".NET Framework 3.0" - .NET 3.0 RTM
  • VS 2008 ".NET Framework 3.5" - .NET 3.5 RTM
  • VS 2008 SP1+ ".NET Framework 3.5" with a reference to System.Data.Entity.dll or using ClickOnce - .NET 3.5 SP1
  • VS 2008 SP1+ ".NET Framework 3.5" without a reference to System.Data.Entity.dll and not using ClickOnce - .NET 3.5 RTM
  • VS 2010 ".NET Framework 3.5" - .NET 3.5 SP1
  • VS 2008 SP1+ ".NET Framework Client Profile" - .NET 3.5 SP1 (client)
  • VS 2010 ".NET Framework 3.5 Client Profile" - .NET 3.5 SP1 (client)
  • VS 2010 ".NET Framework 4.0" - .NET 4.0 RTM
  • VS 2010 ".NET Framework 4.0 Client Profile" - .NET 4.0 RTM (client)

Notes:

  • VS 2008 shipped with .NET 3.5 RTM; VS 2008 SP1 shipped with .NET 3.5 SP1; VS 2010 shipped with .NET 4.0 RTM.
  • VS 2010 is unable to target earlier versions unless they are installed seperately.
  • The client profile was introduced in .NET 3.5 SP1
  • VS 2010 is the first version with extensible multitargeting (so - in theory - it will be able to target future .NET versions without a VS update).

I believe .NET 3.5 SP1 is the only service pack that added significant functionality, so it's the only one that will cause MissingMethodException problems. For example, this would mean that 3.0 RTM, 3.0 SP1, and 3.0 SP2 have the same public API. I haven't found explicit confirmation of this, but the "what's new in .NET" documentation only covers 2.0/3.5/3.5SP1/4.0, so this is a logical conclusion.

VS 2008 SP1 has some weird rules regarding ".NET Framework 3.5" (trying to target SP1 only if it's actually used), but VS2010 just supports targeting .NET 3.5 SP1.

Sources:

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