Download .NET Framework 4.0 targeting pack
Asked Answered
A

6

19

I'm working with an old legacy project that uses .NET Framework v4.0 but I'm having trouble with running it. I cannot update the target framework because this is a massive legacy project that many people rely on. Whenever I try to start up the project I get this dialogue box telling me that I need the .NET Framework 4.0 targeting pack, but when I try to download and install, my system tells me I already have it. Anyone have any ideas for how I can fix this?

enter image description here

When I allow Visual Studio to open my browser, it seems that .NET Framework 4.0 runtime is my only option.

enter image description here

But once I double click on the installer in my downloads folder, I get told that I already have it. enter image description here


Edit: Someone linked another article How to install .NET 4 Framework in Windows 10 but this does not work for me. First, I already have .NET Framework 4.6 installed, and second the download link for the 4.0.3 multi targeting pack no longer works. When I click on the link, it leads me to this article. I tried to click this download link, and it led me to a default store page with nothing to download. Additionally, the article is about Visual Studio 2010, but I am currently using version 2022.

enter image description here enter image description here

Aurochs answered 7/11, 2022 at 22:28 Comment(6)
Normally you can select that from project propertiesCicily
Related: https://mcmap.net/q/456838/-how-to-install-net-4-framework-in-windows-10 - I post a link to the 4.0.3 targeting pack which I think is what you need (I think 4.0 is covered by 4.0.3 - if not there's hardly any changes between the two). As you already saw, you have the runtime already as that is part of Windows. Note that 4.0 is no longer supported by Microsoft (neither is 4.0.3) - though I realise you can't upgrade to 4.8.Sudarium
See if this link helps youInformation
@WaiHaLee while that's a useful thread, your answer isn't. The answers from foxx1337 was the correct one that pointed out what's needed for .NET Framework 4.0 targeting, not 4.0.3.Wareroom
@LexLi - aha- thanks for the clarification. I knew that the 4.0.3 targeting pack definitely covers 4.0.1 and 4.0.2 but wasn't 100% sure about 4.0.Sudarium
To be overly clear, Lex Li is referring to foxx1337's answer at the other question (not to an answer posted here; EricBlousot isn't a new name for foxx1337 or whatever). That said, @EricBlousot's answer seems easier -- use the Visual Studio Installer and grab it under Individual Components. I don't think you need to install 2019 first to do this.Komarek
W
16

I solved this problem downloading VS2019 (https://learn.microsoft.com/en-us/visualstudio/releases/2019/redistribution#vs2019-download) and using the VS Installer to install individual component ".NET Framework 4 Targeting Pack"

Whopping answered 7/6, 2023 at 9:37 Comment(1)
Downloading 'visual studio build tools 2019' is enough to install fw 4.0. Then close and restart vs2022Marya
H
9

I solved this problem by download .net40 package manager from nuget.

https://www.c-sharpcorner.com/article/open-legacy-projects-4-5-framework-in-visual-studio-2022/

Haversack answered 11/8, 2023 at 3:40 Comment(2)
Your answer is spot on, thanks a lot!Chesterton
Works great for all versions exception 4.0.3 and 3.0 (which are not packaged for whatever reason).Amalgamate
G
8

Installing only the Microsoft.NETFramework.ReferenceAssemblies.net40 assembly via nuget did not work for me as this alone would not give me the option to target the .NET 4 framework in Visual Studio 2022. What worked for me is to download the Visual Studio 2019 web installer and install only the ".NET Framework 4.0 targeting pack".

enter image description here

Now I have .NET Framework 4 among the available runtimes to target in VS 2022.

enter image description here

Grantgranta answered 1/11, 2023 at 14:21 Comment(1)
Worked a treat - thanksDrusy
J
3

I solved downloading NETFramework.ReferenceAssemblies.net40 unpak it or rename as .zip then copy content from build\.NETFramework\v4.0\ to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0

Jeunesse answered 22/6 at 19:48 Comment(0)
R
1

I solved this problem by running following command in package manager console in visual studio NuGet\Install-Package Microsoft.NETFramework.ReferenceAssemblies.net40 -Version 1.0.3

Radii answered 21/9, 2023 at 15:54 Comment(1)
Not working here.Marya
V
-1

I could not download visual studio 2019 because I had already installed visual studio 2022 and I did not want to uninstall it. The visual studio build tools 2019 appeared to be unavailable to install so the solution that worked was downloading the reference Assemblies for NETFramework 4.0 in NugetOrgSite.

Nuget Site

Then, after downloading package in the 'About' tab, I simply changed the downloaded package extension to .zip and accessed inside the new zip folder to Downloads\microsoft.netframework.referenceassemblies.net40.1.0.3.zip\build\.NETFramework\v4.0 and copy all folder content to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0. Then, when I restarted the project in visual studio 2022, the .NET Framework 4 was available to use.

Visual Studio Target Frameworks

Veach answered 18/7 at 10:38 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Signification

© 2022 - 2024 — McMap. All rights reserved.