14 January, 2015

Run a C# application both on .NET Framework 3.5 and 4.5

I have an application written in C# and compiled with Visual Studio 2013 with a target framework of ".NET Framework 3.5 Client Profile".
The issue was that the compiled .exe would not run on Windows 8.1 (which has only .NET Framework 4.5 installed).
The solution was to include the app.config file besides the application .exe file.
The source of the .config file would be (sourced from http://stackoverflow.com/a/20865375) :

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" />
    <supportedRuntime version="v2.0.50727"/>
  </startup>
</configuration>
The app.config file is located in the same folder as the compiled .exe.
For example, if you have an executable compiled as clientapp.exe then you should also have the config file clientapp.exe.config in the same folder.
Now the .exe with a target framework of ".NET Framework 3.5 Client Profile" runs fine on a system with only .NET Framework 4.5 installed.

2 comments:

  1. This is amazing and awesome , thanks for sharing

    .Net Online Training

    ReplyDelete
  2. Dried Tomato | Tiƫsto and His Tintages, Tintages, Tintages, Tintages
    Tostitian nano titanium flat iron Tostitian Tostitian Tostitian Tostitian Tostitian Tostitian Tostitian Tostitian Tostitian Tostitian micro titanium trim Tostitian titanium hair trimmer as seen on tv Tostitian Tostitian Tostitian Tostitian Tostitian how to get titanium white octane Tostitian Tostitian Tostitian titanium glasses frames Tostitian Tostitian Tostitian Tostitian

    ReplyDelete