Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET 2 / 3 application refuses to run under .NET 4

Tags:

c#

.net

I have written a small utility to collect system data and output it to a text box. Nothing complex at all, the purpose is to audit a users machine in preparation for a software rollout.

I can't say what version of .NET a user will be operating, so when I created the solution I selected framework 2.0.

Debug and testing the released EXE on my machine is fine. When I load it onto an XP machine with only has .NET 4.0 (full) it refuses to run, advising me that I need to install .NET 2.0. I then updated the release to 3.0 but this did the same thing.

I have .NET 4.0 on the machine, why can't this application run with a greater version installed and how can I make the application execute under all .NET versions?

like image 859
Damo Avatar asked Mar 17 '12 16:03

Damo


1 Answers

What I did in the past was to add the following settings to the "*.exe.config" file of my .NET 2.0 application:

<?xml version="1.0" encoding="utf-8"?>

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

The supportedRuntime element specifies which versions of the .NET runtime your applications can run under.

like image 51
Uwe Keim Avatar answered Oct 31 '22 17:10

Uwe Keim