碰撞对.NET 4运行.NET 3.5的应用程序时, [英] Crash when running a .NET 3.5 app on .NET 4

查看:156
本文介绍了碰撞对.NET 4运行.NET 3.5的应用程序时,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的应用程序正在使用的WinForms在.NET 3.5内置

这是在Windows XP中专门进行了测试,虽然我不知道它是否操作系统有关。

每当我一台机器上运行它与.NET 4中而已,它会崩溃,说找不到.NET程序集版本3.5。

我很奇怪,为什么这不会自动发生。例如,某些第三方库安装某种类型的政策,即安装了新版本的时候,它就会被使用,即使你的应用程序编译的旧版本。

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

无法找到一个版本的运行时运行此程序。

我的问题是:

  1. 为什么这个不一样的.NET框架?
  2. 的解决方案是增加在配置文件中的元素?任何其他解决办法?
解决方案

如果您的计算机没有.NET 3.5安装没有CLR开始为你的应用程序。 .NET 4.0中不会自动使用,因为潜在的兼容性问题,为您的应用程序。第一个测试你的应用程序并不运行在.NET 4.0,然后添加本条您的app.config告诉CLR为preFER运行.NET 4.0,如果present。

 <结构>
   <启动>
      < supportedRuntime版本=v4.0.30319/>
   < /启动>
< /结构>
 

如果.NET 4不是present作为后备的CLR版本对您的应用程序被编译的作为后备。如果你得到消息无法找到一个版本的运行时运行此应用程序的所有失败。

Our application is built using WinForms on .NET 3.5

This was tested specifically on Windows XP, although i am not sure whether it is OS related.

Whenever i run it on a machine with .NET 4 only, it will crash, saying that it cannot find the .NET assemblies versioned 3.5.

I am wondering why this does not happen automatically. For example, some 3rd party libraries install a policy of some sort, that when a newer version is installed, it will be used, even if your application was compiled against an older version.

UPDATE: The exact error message is:

"Unable to find a version of the runtime to run this application".

My questions are:

  1. Why is this not the same with the .NET framework?
  2. The solution is to add the element in the configuration file? Any other solutions?

解决方案

If your computer has no .NET 3.5 installed there is no CLR to start for your app. .NET 4.0 is not automatically used for your app because of potential compatibility issues. First test that your app does run with .NET 4.0 and then add this section to your app.config to tell the CLR to prefer running .NET 4.0 if present.

<configuration>
   <startup>
      <supportedRuntime version="v4.0.30319"/>
   </startup>
</configuration>

If .NET 4 is not present as fallback the CLR version against which you application was compiled against is used as fallback. If all fails you get the message "Unable to find a version of the runtime to run this application".

这篇关于碰撞对.NET 4运行.NET 3.5的应用程序时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆