检测 .NET Framework 3.5 SP1 依赖性(cmp.3.5 w/o SP1)

发布于 2024-07-07 15:45:49 字数 513 浏览 4 评论 0 原文

我在我的机器上使用的是 3.5 SP1,而我们的客户目前使用的是没有 SP1 的 3.5。 我不知道在 VS2008 中有什么方法可以将解决方案或项目定位到没有 SP1 的 3.5,我只安装了带有 SP1 的 3.5。

如果我们使用 3.5 w/o SP1 中不可用的函数或构造函数,代码将无法正常工作。

也就是说,我想在编译时检测没有 SP1 就无法工作的内容。

到目前为止,我们已经完成了测试(在虚拟机或单独的机器中)以查看应用程序是否会中断,并且当我们使用 SP1 之前不可用的部分 API 时,有时它确实会中断。 问题是它仅在代码实际运行时(运行时)中断,而不是在加载程序集时中断。

一种解决方案是拥有一台装有 VS2008 w/o SP1 的机器并尝试编译该项目。 不过,我更喜欢一些工具来帮助我通过分析源代码或我们生成的程序集来检测对 3.5 SP1 的依赖关系(由于使用新的 API 或其他原因)。

我的谷歌力量对这个问题还不够强大,有什么提示吗?

I'm using 3.5 SP1 on my machine, while our customers currently use 3.5 without SP1.
I don't know any way in VS2008 to target the solution or project to 3.5 without SP1, only the 3.5 with SP1 I have installed.

If we use functions or constructors not available in 3.5 w/o SP1 the code will not work properly.

That is, I want to detect at compile time what would not work without SP1.

So far we have done testing (in a VM or separate machine) to see if the application breaks, and it does break sometimes when we've used parts of the API not available until SP1. The problem is that it only breaks when the code actually runs (at runtime), not when the assembly is loaded.

One solution would be to have a machine with VS2008 w/o SP1 and try to compile the project.
However I'd prefer some tool to help me detect a dependency to 3.5 SP1 (due to use of new API, or whatever), either by analyzing the source code, or the assemblies we produce.

My google powers has not been strong enough with this question, any hints?

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

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

发布评论

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

评论(5

看海 2024-07-14 15:45:49

我刚刚遇到了同样的问题,我找到了解决方案。 对于我们的应用程序来说,对 System.Threading.WaitHandle.WaitOne(Int32) 的调用给我们带来了麻烦。 有关 Service Pack 版本中引入的 API 引用如何在 Visual Studio 不注意的情况下泄漏到代码中的更多详细信息,请参阅 Krzysztof Cwalina 的帖子

好消息是,正如 Marc提到的是他的答案,FxCop有一个检测这些泄漏的新规则。 坏消息是,当您以 .NET Framework 3.5 为目标时,该规则在 FxCop 1.36 中被破坏。 然而,David Kean 描述了如何编辑几个 XML 配置文件以 解决问题。 我按照说明操作,FxCop 现在检测到我对服务包 API 的引用。

I just had the same problem, and I found a solution. For our application, it was a call to System.Threading.WaitHandle.WaitOne(Int32) that got us in trouble. For more details on how references to API's that were introduced in service pack releases can leak into your code without Visual Studio noticing, see Krzysztof Cwalina's post.

The good news is that, as Marc mentioned is his answer, FxCop has a new rule that detects these leaks. The bad news is that the rule is broken in FxCop 1.36 when you target .NET Framework 3.5. However, David Kean describes how to edit a couple of XML configuration files to fix the problem. I followed the instructions, and FxCop now detects my references to service pack API's.

埋葬我深情 2024-07-14 15:45:49

这个? (FxCop 的多目标规则)

How about this? (multi-targetting rules for FxCop)

画骨成沙 2024-07-14 15:45:49

您可以使用找到的代码 此处检测已安装的.NET Framework。

You can use the code found here to detect the installed .NET Frameworks.

攒一口袋星星 2024-07-14 15:45:49

字符串 Fx35RegistryKey = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5";
对象 Fx35ServicePack = Registry.GetValue(Fx35RegistryKey, "SP", null);

if (Fx35ServicePack == null || (int)Fx35ServicePack < 1) throw new Exception("需要 .NET Framework 3.5 SP1。");

string Fx35RegistryKey = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5";
object Fx35ServicePack = Registry.GetValue(Fx35RegistryKey, "SP", null);

if (Fx35ServicePack == null || (int)Fx35ServicePack < 1) throw new Exception(".NET Framework 3.5 SP1 is required.");

人心善变 2024-07-14 15:45:49

还有另一种选择,我没有尝试过。 Visual Studio 文档 表示您可以使 ClickOnce 安装程序专门针对.NET 3.5SP1 框架。 点击链接,然后搜索“Targeting .NET Framework Version 3.5 SP1”。 本质上,它表示执行以下任何操作都将强制安装程序安装 3.5SP1:

  • 在“发布选项”对话框中指定错误 URL。
  • 在“发布选项”对话框中指定套件名称。
  • 在“发布选项”对话框中创建桌面快捷方式。
  • 从“应用程序文件”对话框中的哈希值中排除文件。
  • 清除“签名”页面上的“对 ClickOnce 清单进行签名”复选框。
  • 添加对 System.Data.Entity 程序集的引用。

There's another option that I haven't tried. The Visual Studio documentation says that you can make your ClickOnce installer specifically target the .NET 3.5SP1 framework. Follow the link, and search for "Targeting .NET Framework Version 3.5 SP1". Essentially, it says doing any of the following will force the installer to install 3.5SP1:

  • Specify an Error URL in the Publish Options dialog box.
  • Specify a Suite name in the Publish Options dialog box.
  • Create a desktop shortcut in the Publish Options dialog box.
  • Exclude a file from the hash in the Application Files dialog box.
  • Clear the Sign the ClickOnce manifests check box on the Signing page.
  • Add a reference to the System.Data.Entity assembly.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文