29

How can I install the .NET 4.0 Framework in Windows 10? .NET 4.6 is already installed but I want to have .NET 4 Framework (without modifying the registry).

Turning on and off Windows features in control panel does not have any effect.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Ho Pam
  • 435
  • 1
  • 4
  • 6
  • is this a real question? Just assume its there no need to do any more work. You can select what to compile for in Visual studio – Thomas Andreè Wang Mar 01 '16 at 20:44
  • visual studio? I want to install an x64 application... i just need the right compiler and that needs this framework – Ho Pam Mar 01 '16 at 21:00
  • https://www.google.no/search?q=download+.net+4 – Thomas Andreè Wang Mar 01 '16 at 21:02
  • 6
    ...thanks but I already have downloaded this one. Just to let you know, on W10 .NET 4.6 is installed so .NET 4 cannot be installed. Please help me with that. – Ho Pam Mar 01 '16 at 21:20
  • 12
    This is a very real issue and I truly don't understand these downvotes. I'm currently struggling to install winSDK 7.1 on a win10 machine, and since .net 4.0 is missing (and can't be installed directly!) some SDK components - specifically compilers - refuse to install. Also apparently I'm not the only one: https://www.mathworks.com/matlabcentral/answers/101105#comment_373830 – Ofek Shilon Jun 28 '16 at 10:05
  • Same issue with non-matlab environment. I've installed Visual Studio 2015 on Windows 7 machine (not windows 10, please note). I don't have .net framework 4, only 4.5, 4.5.1, 4.6 + (Which have been installed within VS). Now the issue : i need to compile C++ project targeting VS2010 compiler. Yes, AFAIU - I can try install VS2010 after 2015 and pray that everything goes smooth. But trying install winSDK 7.1, 2010 compiler tools or simply .net 4 manually - C++ components refuse to install like @ofek-shilon said. – Ruslan Makrenko Jul 08 '17 at 04:00

5 Answers5

25

If you really want to install the development part of .NET 4.0 or 4.5.2 in Windows 10 you need, depending on the version, the following:

  1. The libraries:

  2. The tools (csc, msbuild): grab the 2017 versions, the newest, as they'll work with both 4.5.2 or 4.0 from before. Go to the Visual Studio downloads site, scroll down and download from way below the Build Tools for Visual Studio 2017 package.

    From the setup you'll need the following Individual components:

    • .NET Framework 4.6.1 SDK
    • .NET Framework 4.6.1 targetting pack (they're useful because they bring nice executables such as tlbimp.exe for example)
    • C# and Visual Basic Roslyn compilers (brings csc.exe and msbuild.exe)

You should be golden now!

foxx1337
  • 1,859
  • 3
  • 19
  • 23
  • 8
    This didn't quite work for me (Rider and the 4.0.3 pack didn't recognize 4.0 as being installed), but it got me close, so much appreciated. After downloading the SDK as per above instead of running `Setup\SDKSetup.exe`, I navigated to `Setup\MTPack` in a command prompt and ran `NetFx_DTP.msi EXTUI=1` to install the 4.0 Multi-Targeting Pack without any other components. The rest should be as per the steps outlined, though I already had 4.8 SDK installed so didn't need to do anything else to run my ancient project in Rider. Note that he same MSI file is also on the VS 2010 disk if you prefer. – StormFoo May 29 '21 at 17:36
15

From the download page for the "Microsoft .NET Framework 4.6" (emphasis mine):

The Microsoft .NET Framework 4.6 is a highly compatible, in-place update to the Microsoft .NET Framework 4, Microsoft .NET Framework 4.5, Microsoft .NET Framework 4.5.1 and Microsoft .NET Framework 4.5.2.

On other words, having .NET 4.6 installed (it's part of Windows 10 so you need not manually install it) means you have .NET 4.0, 4.5, 4.5.1, 4.5.2 and 4.6 installed and can run code targeting any of those framework versions without making any modifications to your Windows installation.

You cannot install .NET 4.0 when you have a later version installed as each version is an in-place update to the last.


If, however, your problem is with opening a project which targets .NET 4.0.1, 4.0.2, or 4.0.3 in Visual Studio on Windows 10, you may need to download the targeting pack for .NET 4.0.3:

Multi-Targeting Pack for .NET 4.0.3

as I'm not sure they are installed. Note that (emphasis mine)

Multi-Targeting Pack for the Microsoft .NET Framework 4.0.3 is cumulative. It includes all the related files from multi-targeting packs for the .NET Framework 4.0.1 and for the .NET Framework 4.0.2. Therefore, you do not have to install the previous multi-targeting packs separately after you install Multi-Targeting Pack for the Microsoft .NET Framework 4.0.3 for building any new projects.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
  • 2
    But why can't I install an exe file if it keeps on saying that it needs .NET framework 4 is missing if I already have .NET 4.6? Perhaps compatibility mode , right clicking, properties and setting compatibility Windows 7 will do the job. Thank you for an answer, not all people know everything about computers. – Ho Pam Mar 01 '16 at 23:07
  • What error (if any) do/did you get when installing it? – Wai Ha Lee Mar 01 '16 at 23:14
  • 4
    I don't know what the OP was getting, but trying to install Windows SDK 7.1 on windows 10 I get: "Some Windows SDK components require the RTM .NET Framework 4. Setup detected a pre-release version of the .NET Framework 4. If you continue with Setup, these components will not be installed". So here's an installer that explicitly requires .net 4 and I can't seem to indulge it. – Ofek Shilon Jun 28 '16 at 09:56
  • 1
    Hmm. Have a look at this other question: "[*Cannot install Windows SDK 7.1 on Windows 10*](http://stackoverflow.com/q/32091593/1364007)" - might be helpful. – Wai Ha Lee Jun 28 '16 at 10:00
  • To target 4.0 or to install the target packs listed above, I had to install the original Multi-Targeting Pack for .NET 4.0, but it complains if you try to install it outside of the VS 2010 or Windows 7 SDK installer unless you pass `EXTUI=1` to the MSI. See my comment on foxx1337's answer for steps to take. Once done I was able to install the other targeting packs. – StormFoo May 29 '21 at 17:40
  • I have a project that is targeted .NET Farmework 4.0 not 4.0.1, 4.0.2 or 4.0.3. Do I need to install .NET Framework 4.0 still? – Inês Borges Jun 09 '22 at 16:19
  • @WaiHaLee Unfortunately the links you posted point to links that no longer exist. If you go to MS Downloads site directly and search for it, you're redirected back to those articles. – user3953989 Sep 07 '22 at 17:32
  • 1
    @user3953989 - thanks for spotting that. Microsoft are awful with their URLs and there are often links whose URL changes (or are deleted altogether). I've updated the URLs and the accompanying text. – Wai Ha Lee Sep 09 '22 at 10:26
2

I have experienced, I have to open and work with an old project that is required .Net 4.0 to build (they're related to some old libraries) and can not be updated to new .Net version.

I did try to uninstall the current .Net version (4.6, 4.8) and to install .Net 4.0 standalone (dotNetFx40_Full_x86_x64.exe) but it doesn't work. And I finally decided to install the old Visual Studio (2019) with only some basic features that I manually checked to be lightweight, it works well now.

Toan NC
  • 2,960
  • 1
  • 14
  • 6
  • Yep, the only thing that worked for me was installing VS 2019 and just choosing the .NET 4.0 targeting pack... They should just change the installers to always install. Having to install an old version of Visual Studio just to be able to build projects in a newer version is ridiculous at best. – Josh Jul 28 '23 at 11:44
0

If you manage to use a tool to remove Net Framework 4+ from Windows 10 ISO for a fresh install.

Then you can then install a fresh install of Net Framework 4.5, not 4.0. Since Windows 10 would not allow that for 4.0.

I'm really unsure if there are some removal tools for 4.6 and 4.7. Since I've tried the direct way to work with installation of 7 SDK. But then only 4.5 is able to be installed.

Then it's possible to install Windows 7 SDK fully, when you install 4.5.

If Windows 7 SDK cries for 2.0 or 3.5 install it in the apps and features.

You can use a tool called NTlite and edit the .wim file installation of Windows 10. Then use compatibles to remove 4+. Then save and start up the copied ISO in C:, and start an installation in Windows 10. That way you also can keep settings and apps that you already installed, just removing main source files of Windows 10. Also keeping your Windows Activated.

Dealazer
  • 59
  • 4
-1

You can not install older version. As you're already running on .Net framework 4.6, it is not possible to downgrade it. However, Windows 10 already comes with .NET framework by default, why do you need to install the older version?

According to this website, you can either choose web installer or offline installer for installing .NET framework. You can try downloading the .NET framework 4 from here.

Uday
  • 275
  • 1
  • 4
  • 15