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

Lee Feng 171 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.)

Developer technologies .NET .NET Runtime
Developer technologies Visual Studio Debugging
Windows for business Windows Client for IT Pros User experience Other
Developer technologies C#
{count} votes

6 answers

Sort by: Most helpful
  1. Lee Feng 171 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.

    29 people found this answer helpful.

  2. Luis Espinoza 81 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.

    16 people found this answer helpful.

  3. Jiachen Li-MSFT 34,221 Reputation points Microsoft External Staff
    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. David Goben 60 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.

    1 person found this answer helpful.
    0 comments No comments

  5. Limitless Technology 39,916 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--


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.