Running .NET 3.5 apps on .NET 4 only systems

守給你的承諾、 提交于 2019-11-30 08:31:59

问题


This question has been asked before perhaps multiple times, but I can't get the typical solution to work for me. The proposed solution is to put this in the "app.config" file:

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

But with a simple "Hello World" program, I still get the error: "Unable to find a version of the runtime to run this application.".

For some background, I'm using Windows XP (through Windows Virtual PC on Windows 7), and only installed the .NET 4.0 runtime on XP.

After some research, I found this page: http://msdn.microsoft.com/en-us/library/ee941656.aspx#core

It mentioned "If your application configuration file is named application-name.config, rename it to application-name.exe.config. For example, rename MyApp.config to MyApp.exe.config.".

I tried that, thinking it could solve the issue, but I still get "Unable to find a version of the runtime to run this application." when I try to run the .NET 3.5 (client profile or full) application on WinXP with .NET 4.0.


回答1:


I cracked it. This might sound daft, but it turns out that the config file needed to be with the final executable in the user's folder. After all my researching, this didn't appear to be clarified anywhere. I was thinking it was only used for compiling purposes to be in the developer's folder.

In the VS editor file list, it can remain as "app.config". However, when compiled, VS automatically creates "{ProgramName}.exe.config" instead (and puts it in the bin/release folder). This is the file that needs to go in the end user's folder along with the executable.

To summarize, yes, it is possible to run a .NET 3.5 app on a system which only has .NET 4.0 installed.



来源:https://stackoverflow.com/questions/9959743/running-net-3-5-apps-on-net-4-only-systems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!