Search code examples
c#.netvisual-studio.net-2.0.net-framework-version

How do I compile a simple WinForms C# application for .NET Framework 2.0 in Visual Studio 2005 or 2019?


I need to create a very simple WinForms C# application that only requires .NET Framework 2.0 to execute properly (due to the fact that the customer isn't allowed to upgrade or connect his computer to the Internet).

On my computer I have Visual Studio (VS) 2005 and VS2019 installed.

  1. I first tried VS2005 and created an empty WinForms application and sprinkled the project file with <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> tags and compiled.
  2. I then checked the .exe-file inside JetBrains dotPeek (according to a tip I found on How to find out which version of the .NET Framework an executable needs to run?) but it says it's .NET 3.5 application.
  3. I then tried with VS2019, but I didn't have to manipulate the project file manually, instead I used the user-friendly dropdown for selecting target framework and set it to 2.0. However, the result was the same, the application became a .NET 3.5 application.

Does anybody know what I'm doing wrong?


Solution

  • The problem appears to be that JetBrains dotPeek is not reliable. I tried an .exe-file that JetBrains dotPeek reported was using .NET Framework 3.5, but I had no problems executing it on computer with only Windows 2000 and .NET Framework 2.0 installed. I agree with this answer How to find out which version of the .NET Framework an executable needs to run? that it's better to inspect the .exe-file in Notepad to determine which .NET version it requires.