Sunday, April 17, 2011

Unable to Turn On .NET Framework 3.5.1 {PEN001}

If you receive the message, "An error has occurred. Not all of the features were successfully changed." when trying to turn on the .NET Framework 3.5.1 Windows feature in Windows 7, the following may help.

In an adminstrative command prompt, type:


%SystemDrive%
 
cd %SystemRoot%\Microsoft.NET\Framework\v2.0.50727\CONFIG
 
copy machine.config.default machine.config
 
copy web.config.default web.config
 
copy web_hightrust.config.default web_hightrust.config
 
copy web_lowtrust.config.default web_lowtrust.config
 
copy web_mediumtrust.config.default web_mediumtrust.config
 
copy web_minimaltrust.config.default web_minimaltrust.config
 

(If you're feeling lazy, run the batch file instead.)

Open the Windows Features control panel applet and try turning on .NET Framework 3.5.1 again.


After perusing "CBS.log" in "%SystemRoot%\Logs\CBS", I discovered that the built-in installer of .NET Framework 3.5.1 expects to find these files properly configured. If it can't, it rolls back the entire installation and prompts you to restart (?!). Luckily, .NET 2.0.50727 comes packed with .default files that are templates for real configuration files. The batch file above just makes copies of these files.

I'm not sure exactly what brought about this conundrum. It may have been the .NET Framework Cleanup Tool, or some other such "helpful" utility. Either way, it's solved now and I can continue to customise the Windows 7 logon screen using the dirty .NET-based tool presumably built by a twelve-year-old that I found.