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

Lee Feng 136 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.
10,249 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,119 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.
939 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,167 questions
0 comments No comments
{count} votes

6 answers

Sort by: Most helpful
  1. Lee Feng 136 Reputation points
    2022-09-06T12:38:21.127+00:00

    OK I found a solution. Hope it can help if you are facing the similar problem.

    Just download VS 2019. In the installer check .NET 4 multi targeting pack only (no need to install other payloads). Install.

    Then VS 2022 should be able to build projects targeting 4.0.

    23 people found this answer helpful.

  2. Luis Espinoza 56 Reputation points
    2022-10-29T04:26:09.55+00:00

    Hi, just download the reference assemblies from nuget.org (click on the "Download package" link) open the file as zip and paste the content of the folder build\.NETFramework\ into Program files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework.

    11 people found this answer helpful.

  3. Jiachen Li-MSFT 26,506 Reputation points Microsoft Vendor
    2022-09-05T08:05:48.16+00:00

    Hi @Lee Feng ,
    According to Install .NET Framework for developers

    Starting with Visual Studio 2022, Visual Studio no longer includes .NET Framework components for .NET Framework 4.0 - 4.5.1 because these versions are no longer supported. Visual Studio 2022 and later versions can't build apps that target .NET Framework 4.0 through .NET Framework 4.5.1. To continue building these apps, you can use Visual Studio 2019 or an earlier version.

    Best Regards.
    Jiachen Li

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    3 people found this answer helpful.
    0 comments No comments

  4. Limitless Technology 39,356 Reputation points
    2022-09-09T08:36:52.2+00:00

    Hello,

    Thanks for posting the query here and I'm happy to help you regarding this Dot NET upgrade.

    If you have VS 2022 installed, it should have included latest dot net versions.

    Please find below link to download load latest version of .Net 4.8.1 - https://dotnet.microsoft.com/en-us/download/dotnet-framework/net48

    Here is a helpful page with information on .NET

    https://learn.microsoft.com/en-us/dotnet/

    --------------------------------------------------------------------------------------------------------------------------------

    --If the reply is helpful, please Upvote and Accept as answer--


  5. David Goben 40 Reputation points
    2023-02-08T11:31:42.6366667+00:00

    Just an observation.

    Although the .NET 4 Multi Targeting Pack is not available to Community Editions, one might notice we can still build existing .NET 4 Framework projects in VB2022 Community Edition. Therefore, take a copy of any old VB project, strip it down to bare bones, and use it as a "Framework4" Project Template to build fresh .NET 4 Framework Class Library projects under VB2019 or VB2022 Community Editions. I use a tiny already-bare-bones test console application and added a form window. This can be easily transformed into a windowed project with quick selections in the project properties.

    0 comments No comments