Running .NET 3.5 apps on .NET 4 only systems
Asked Answered
A

1

8

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.

Airplane answered 31/3, 2012 at 21:15 Comment(6)
This is known to work well. You didn't actually rename it to "MyApp.exe.config", did you? Replace MyApp with the name of your program.Ghiberti
Nope, I renamed it from "app.config" to "app.exe.config" since it was already named "app.config". The name of my program is actually "testOnNet40only". Nathan below seems to imply the user needs CLR 2.0-3.5 after all though, so I'm not sure if anything will work.Airplane
That seems to be what I'm talking about. "app.exe.config" is no good, you have to name it "testOnNet40Only.exe.config". And if you use the debugger with the hosting process enabled then it needs to be named "testOnNet40Only.vshost.exe.config".Ghiberti
Still doesn't work. As a reality check, I tried compiling it to .NET 4.0, and that worked perfectly. No luck with compiling to 3.5 however - any other ideas? Nathan seems to have removed his answer.Airplane
Do you have "hide file extensions on" in Windows? I bet the file is named "application.exe.config.txt" or something similar.Yarrow
That wasn't the problem, but the way you said that (implication of almost me 'supplying' the file, rather than VS) led me to find the actual answer. Maybe I can give you and Hans half the bounty each (not that you need it ;) )Airplane
A
6

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.

Airplane answered 3/4, 2012 at 14:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.