2

First, I´ve found a few questions on this topic but none seem to address exactly my issues, but feel free to point to an existing question if you feel it does answer my questions.

My problem: I am building a C# .NET app that depends on .NET Framework 3.5 or above. My main problem is on the "or above" part.

The app was working perfectly if the target machine had exactly the version 3.5 installed (and I hadnt changed anything on the app.config). But now I tested on a machine that has 4.0 only (ie, doesnt have 3.5) and it didnt work, it says:

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

And, btw, my installer detects that there is a compatible .NET version (ie, a version >= 3.5), so it allows the app to install, but it wont run after installed.

Then researching I found out that you had to change app.config and add the other .NET Framework versions, so I added:

supportedRuntime version="v4.0.30319"

(full app.config:

 <?xml version="1.0"?>
    <configuration>
    <startup>
      <supportedRuntime version="v4.0.30319"/>
      <supportedRuntime version="v2.0.50727"/>
    </startup>
    </configuration>

)

After I added this, I started getting warnings saying "Could not find schema information for the attribute "version" (and element "supportedRuntime")", and when I run it on the .NET-4.0-only-machine it will give me the same error message as before.

My project is set to 3.5 as target-runtime on project properties.

Any ideas?

Thanks in advance.

pertz
  • 394
  • 4
  • 14
  • Post the *exact* content of the .config file. It cannot look the way you have it now. – Hans Passant Apr 02 '12 at 17:21
  • possible duplicate of [Force an application to run under specific .NET runtime version?](http://stackoverflow.com/questions/2046089/force-an-application-to-run-under-specific-net-runtime-version) – Hans Passant Apr 02 '12 at 17:23
  • Here goes: – pertz Apr 02 '12 at 17:43
  • Next problem: it is not app.config, it is foo.exe.config where "foo" is the name of your exe file. And foo.exe.config must be in the same directory as foo.exe – Hans Passant Apr 02 '12 at 17:47
  • Uhmmm, that seems to have to do with the problem. I copied manually app.config to the other machine, under the same directory, keeping the pattern you mentioned (foo.exe.config) and it worked. 3 questions/points, please use a full-answer and not comment so I can accept: 1) It stills gives me the warnings (of course, since I dindt change anything on the code); 2) Shouldnt Visual Studio somehow use the app.config I edited on the release build (since VS created originally that config file)?; 3) Do I have to distribute this config file together with the executable? – pertz Apr 02 '12 at 17:58
  • So did you manage to find the solution to your problem? – SF Lee Aug 13 '14 at 04:07

1 Answers1

3

I've never seen anyone specify .NET 4 in the app.config as "v4.0.30319", you only need to specify it as "v4.0". See this page for more.

Changing that should take care of your problem.

Steve Danner
  • 21,818
  • 7
  • 41
  • 51
  • I had tried v4.0 also, forgot to mention, sorry. I read that suggestion during the research. It continues to give me the warnings and fails to run on the v4.0-only-machine. – pertz Apr 02 '12 at 17:42