碰撞对.NET 4运行.NET 3.5的应用程序时,应用程序、NET

由网友(时而傻笑时而心酸)分享简介:我们的应用程序正在使用的WinForms在.NET 3.5内置这是在Windows XP中专门进行了测试,虽然我不知道它是否操作系统有关。每当我一台机器上运行它与.NET 4中而已,它会崩溃,说找不到.NET程序集版本3.5。我很奇怪,为什么这不会自动发生。例如,某些第三方库安装某种类型的政策,即安装了新版本的时候,它...

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

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

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

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

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

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

我的问题是:

为什么这个不一样的.NET框架? 的解决方案是增加在配置文件中的元素?任何其他解决办法? 解决方案 网络人远程控制软件企业版下载 网络人远程控制软件企业版电脑版下载V6.562

如果您的计算机没有.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:

Why is this not the same with the .NET framework? 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".

阅读全文

相关推荐

最新文章