How to target .NET Framework 4.0 in VS 2022 on Windows 11?

Lee Feng 156 Reputation points
2022-09-05T07:41:23.313+00:00

Working on some old projects targeting .NET Framework 4.0. I used VS 2022 to open the solution and was told to install 4.0 targeting pack.

I can't find the download link on the dotnet website, nor the installation option in Visual Studio Installer.

Anyway to install it?

(Of course I know it's no longer supported. But I cannot just make it target a newer version, because my boss does not let me do that.)

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,065 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,173 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
1,006 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
10,033 questions
0 comments No comments
{count} votes

7 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Ziya Ganjili 20 Reputation points
    2024-05-21T04:59:14.85+00:00

    I want to upgrade Netframework to NET 8.0. On sqlproj file I am mentioning frameworkVersion
    <TargetFrameworkVersion>net8.0<TargetFrameworkversion> but cant load project getting error:

    The expression "[MSBuild]::VersionGreaterThanOrEquals(net8.0, 4.0 )" cannot be evaluated. Version string was not in the correct format.
    trying load without TargetframeworkVerison it recommends I should upgrade it .net framework 4.8 but I want .net 8.0 how to fix?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.