c# - 在 .NET 4 上运行 .NET 3.5 应用程序时崩溃

标签 c# .net .net-4.0 clr compatibility

我们的应用程序是在 .NET 3.5 上使用 WinForms 构建的

这是专门在 Windows XP 上测试的,虽然我不确定它是否与操作系统相关。

每当我在一台只有 .NET 4 的机器上运行它时,它就会崩溃,提示找不到 .NET 程序集版本 3.5。

我想知道为什么这不会自动发生。例如,某些第 3 方库会安装某种策略,即当安装新版本时,将使用它,即使您的应用程序是针对旧版本编译的。

更新:确切的错误信息是:

“无法找到运行此应用程序的运行时版本”。

我的问题是:

  1. 为什么这与 .NET 框架不同?
  2. 解决方案是在配置文件中添加元素?还有其他解决方案吗?

最佳答案

一般来说,不应该是这样的:

http://msdn.microsoft.com/en-us/library/ff602939.aspx

Backward compatibility means that an application developed for a particular version of a platform will run on later versions of that platform. The .NET Framework tries to maximize backward compatibility: Source code written for one version of the .NET Framework should compile on later versions of the .NET Framework, and binaries that run on one version of the .NET Framework should behave identically on later versions of the .NET Framework.

...

The .NET Framework 4 is backward-compatible with applications that were built with the .NET Framework versions 1.1, 2.0, 3.0, and 3.5. In other words, applications and components built with previous versions of the .NET Framework will work on the .NET Framework 4.

建议:

1) 阅读这些链接:

2) 查看是否可以使用最小的 .Net 3.5 Winforms 应用重现该问题

3) 剪切/粘贴确切的错误消息和任何相关代码(例如来自您的独立应用程序)

4) 其他都失败了,考虑添加 <startup useLegacyV2RuntimeActivationPolicy="true" >到您的 CLR 启动配置。除了临时解决方法外,我不会推荐此方法:

关于c# - 在 .NET 4 上运行 .NET 3.5 应用程序时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10630464/

相关文章:

c# - 符号已创建,但调试永远不会在断点处停止

.NET 4.0 解决方案中的 NHibernate 1.2

c# - .NET 4 中的 Math.Round() 行为

c# - 如何修复向多个收件人发送邮件时抛出的异常?

c# - Rotativa pdf 转换器在服务器上运行速度非常慢

c# - 'CREATE VIEW' 必须是查询批处理中的第一个语句

c# - 实现具有中止能力的方法

c# - 如何知道 Visual Studio 项目项是否为 WebReference?

c# - 如何在 .NET 中进行持续测试?

c# - 如何查找使用指令