Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install .NET 4 Framework in Windows 10

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.

like image 479
Ho Pam Avatar asked Mar 01 '16 20:03

Ho Pam


People also ask

Does Windows 10 come with .NET 4?

NET Framework 4.8 is included with: Windows 10 May 2021 Update.

Does .NET Framework 4.5 work on Windows 10?

NET 4.5. 1 cannot be installed on Windows 10, only 4.6 and later. So if your application is incompatible with . NET 4.6 and later you will need to update your application.


3 Answers

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:

    • for 4.5.2, grab the .NET framework 4.5.2 Developer Pack

    • for 4.0, grab the Microsoft Windows SDK for Windows 7 and .NET Framework 4 (ISO), mount it and run Setup\SDKSetup.exe (the autorun will cry that .NET 4 isn't available in Windows 10 so go directly to SDKSetup.exe). Note that you'll need to grab GRMSDKX_~, which is probably the x64 version out of the 3 available there, {x86, itanium, x64}, otherwise it cries about not finding some file.

      Anyways, install from there only 1 package - .NET Development\Intellisense and Reference Assemblies and move further.

      • upgrade 4.0 to the latest 4.0.3 with the Multi-Targeting Pack for Microsoft .NET Framework 4.0.3 (KB2600213)
  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!

like image 62
foxx1337 Avatar answered Oct 18 '22 18:10

foxx1337


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.

like image 45
Wai Ha Lee Avatar answered Oct 18 '22 20:10

Wai Ha Lee


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.

like image 1
Toan NC Avatar answered Oct 18 '22 20:10

Toan NC