Partilhar via


How to automate the install of the .NET Framework 3.0 OS component on Windows Vista and Windows Server 2008

Windows Vista and Windows Server 2008 include the .NET Framework 2.0 and 3.0 as OS components.  However, it is possible to turn off the .NET Framework 3.0 component on both of these operating systems so it is not available for applications to use.  In addition, the .NET Framework 3.0 is not installed by default on Windows Server 2008.

How the .NET Framework 3.5 setup.exe handles the .NET Framework 3.0 component

The .NET Framework 3.5 requires the .NET Framework 3.0 as a prerequisite, and the ability to turn off the .NET Framework 3.0 on Windows Vista and Windows Server 2008 can complicate the steps required to deploy the .NET Framework 3.5 on these operating systems.

There is logic within the setup.exe wrapper for the .NET Framework 3.5 to add the .NET Framework 3.0 OS component on Windows Vista and Windows Server 2008 if it is not currently present on the system.  This ensures that you cannot install the .NET Framework 3.5 without first satisfying the .NET Framework 3.0 prerequisite when installing using the setup.exe wrapper.

What happens if you install the .NET Framework 3.5 without 3.0

However, if you are using the instructions in the .NET Framework 3.5 Administrator Deployment Guide to create an administrative install point and then deploying the .NET Framework 3.5 MSI directly, you will see the .NET Framework 3.5 MSI install successfully even if the .NET Framework 3.0 OS component is not present on the system.  There is a blocking custom action within the MSI that is designed to enforce this prerequisite, but it is incorrectly conditioned to not run on Windows Vista or higher.

To make matters worse, if you install the .NET Framework 3.5 MSI on a Windows Vista or Windows Server 2008 system that does not have the .NET Framework 3.0 OS component installed, you will likely encounter exceptions while trying to run applications that depend on the .NET Framework (for example - the ServerManagerCmd tool or the MMC snap-in host).  When a system is in this state, you cannot go to the Programs and Features control panel to add the .NET Framework 3.0 OS component because the Windows Features control panel is hosted by the MMC snap-in host.

If you end up with a system in this state, you will have to run a command line (listed below) to add the .NET Framework 3.0 OS component, or remove the .NET Framework 3.5 using the Programs and Features control panel, add the .NET Framework 3.0 OS component and then re-install the .NET Framework 3.5.

How to install the .NET Framework 3.0 OS component in a deployment scenario

For .NET Framework 3.5 deployment scenarios on Windows Vista and Windows Server 2008 that involve installing the 3.5 MSI directly, I recommend that you add logic to your deployment process to check for the existence of the .NET Framework 3.0 OS component, and trigger the install of this OS component if it is not present.  You can use the following registry value to determine whether or not the .NET Framework 3.0 OS component is installed:

[HKEY_LOCAL_MACHINE\Software\Microsoft\NET Framework Setup\NDP\v3.0\Setup]
InstallSuccess=1

If the .NET Framework 3.0 OS component is not installed, the following command line can be used to trigger an install of this component on Windows Vista and Windows Server 2008:

%windir%\system32\OCSetup.exe NetFx3 /quiet /norestart

The above registry value is the same one used by the setup.exe wrapper for the .NET Framework 3.5 and the same one used in the sample code for .NET Framework detection that I have previously published (which is based on the official .NET Framework 3.0 deployment guide).  In addition, the above install command line is the same one used by the setup.exe wrapper for the .NET Framework 3.5 to add the .NET Framework 3.0 OS component on Windows Vista and Windows Server 2008 systems that it is not currently installed on.

A note about ServerManagerCmd

In addition to the above registry value, there is a tool that ships with Windows Server 2008 named ServerManagerCmd that can be used to query the installed state of OS components such as the .NET Framework 3.0.  Some information about how to use this tool can be found in the Overview of Server Manager Commands topic on TechNet.  When using the -query flag, you will get output like the following snippet on a system that has the .NET Framework 3.0 OS component installed:

2196: 2008-03-25 11:11:11.111 [ServerManagerCmd]          ----- Features -----
2196: 2008-03-25 11:11:11.111 [ServerManagerCmd]         
2196: 2008-03-25 11:11:11.111 [ServerManagerCmd]          [X] .NET Framework 3.0 Features  [NET-Framework]
2196: 2008-03-25 11:11:11.111 [ServerManagerCmd]              [X] .NET Framework 3.0  [NET-Framework-Core]
2196: 2008-03-25 11:11:11.111 [ServerManagerCmd]              [ ] XPS Viewer  [NET-XPS-Viewer]
2196: 2008-03-25 11:11:11.111 [ServerManagerCmd]              [ ] WCF Activation  [NET-Win-CFAC]
2196: 2008-03-25 11:11:11.111 [ServerManagerCmd]                  [ ] HTTP Activation  [NET-HTTP-Activation]
2196: 2008-03-25 11:11:11.111 [ServerManagerCmd]                  [ ] Non-HTTP Activation  [NET-Non-HTTP-Activ]

Note that there are several sub-components listed under the .NET Framework 3.0 feature in this example output.  You do not need the XPS Viewer or WCF Activation features enabled in order to be able to successfully use the .NET Framework 3.0 or install the .NET Framework 3.5.

Comments

  • Anonymous
    July 13, 2008
    The .NET Framework 3.5 setup package is a chainer that installs multiple packages behind the scenes. 

  • Anonymous
    April 08, 2009
    The comment has been removed

  • Anonymous
    November 05, 2009
    This is excellent post and resolved our issue with Windows Server 2008 R2 Standard.  We had to manually add the DWord, rebooted and the 3.5 installation was successful. thank you.

  • Anonymous
    August 09, 2010
    Nice easy to follow guide. Was a quick and painless process...

  • Anonymous
    January 04, 2011
    This post saved me.  Our Windows 2008 R2 machine had .Net 3.5 corrupt and could not fix it because mmc.exe could not create snap-in.  This meant we weren't able to reinstall 3.5 via the Server Manager.  I don't know why, but there was never a .Net 3.0 folder in C:WindowsMicrosoft.NETFramework64 while 2.0.50727 and 3.5 were there.  Running the .Net Verifier (www.softpedia.com/.../NET-Framework-Setup-Verification-Utility.shtml) confirmed that 3.0 files were missing from the 3.5 setup (weird...I know).  Anyways, running OCSetup.exe NetFx3 /quiet /norestart fixed the problem.  Thanks astebner. Also, be sure to delete any mmc.exe.config files you may have added by other fixes posted on the net.

  • Anonymous
    December 14, 2014
    Hallo Aaron, We have a problem with a Server2008 x86, AD and Fileserver. It started with the error MMC could not create the snap-in CLSID:FX:{18ea3f92-d6aa-41d9-a205-2023400c8fbb} after an update from Microsoft. I tried all kinds of tips we could find without any solution. I figured if I use the .Net Framework clean-up tool and rebuild the .Net Framework it will solve the problem, but it didn’t, I cannot install .Net 3.0 and also not 3.5 of course. When I use your tip  "%windir%system32OCSetup.exe NetFx3 /quiet /norestart" I get no result. In the log from the .Net Framework Setup Verification Utility is still no .Net Framework 3.0 and if I try with the Servermanagercmd I get CLR error 80004005 I hope you can help me otherwise we have to rebuild a new server.

  • Anonymous
    December 15, 2014
    Hi Ernst Woning - The .NET Framework cleanup tool does not allow you to remove versions of the .NET Framework that are installed as a part of the OS, so that won't help you in this scenario.  Here are the steps that I typically suggest for people who need to repair versions of the .NET Framework that are installed as a part of the OS:

  1.  Install the latest Windows service pack and updates if you haven't yet.
  2.  Try to run the System Update Readiness Tool from support.microsoft.com/.../947821.
  3.  Try to repair the files that are a part of your OS by using the steps listed at blogs.msdn.com/.../how-to-repair-the-net-framework-2-0-and-3-0-on-windows-vista.aspx. If none of the above help, you might need to repair/re-install Windows to fix this type of error.  It might also help to post a question on one of the Windows forums to see if someone there has any additional suggestions for you to try before you resort to re-installing Windows.