"25007.Error occurred while initializing fusion. Setup could not load fusion with LoadLibraryShim(). Error: The handle is invalid."

While Installing .Net Framework 2.0, you may receive the following error "25007.Error occurred while initializing fusion. Setup could not load fusion with LoadLibraryShim(). Error: The handle is invalid."

From the verbose log:

07/09/10 12:59:23 DDSet_Status: CustomActionData: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.VisualBasic.Vsa.dll;28672
07/09/10 12:59:23 DDSet_Status: Loading mscoree.dll
07/09/10 12:59:23 DDSet_Status: Loading fusion.dll using LoadLibraryShim()
07/09/10 12:59:23 DDSet_Error: Error occurred while initializing fusion. Setup could not load fusion with LoadLibraryShim(). Error: The handle is invalid.

MSI (c) (98:B0) [12:59:23:588]: Font created. Charset: Req=0, Ret=0, Font: Req=MS Shell Dlg, Ret=MS Shell Dlg

Error 25007.Error occurred while initializing fusion. Setup could not load fusion with LoadLibraryShim(). Error: The handle is invalid.

Even if you try installing .Net Framework 2.0 SP2 on the system, you would find the following log snippet:

MSI (s) (E4:94) [15:30:26:250]: Executing op: ActionStart(Name=CA_NgenServiceVersionCheck.3643236F_FC70_11D3_A536_0090278A1BB8,,)
MSI (s) (E4:94) [15:30:26:250]: Executing op: CustomActionSchedule(Action=CA_NgenServiceVersionCheck.3643236F_FC70_11D3_A536_0090278A1BB8,ActionType=1025,Source=BinaryData,Target=NgenServiceVersionCheck,CustomActionData=C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\mscorsvc.dll;C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\mscorsvw.exe;C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\ngen.exe;)
MSI (s) (E4:9C) [15:30:26:250]: Invoking remote custom action. DLL: C:\WINDOWS\Installer\MSIA0.tmp, Entrypoint: NgenServiceVersionCheck
07/08/10 15:30:26 DDSet_Status: LANGID: 1033
07/08/10 15:30:26 DDSet_Entry: NgenServiceVersionCheck started - Ngen Service Version Check
07/08/10 15:30:26 DDSet_Status: Custom Action Data: C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\mscorsvc.dll;C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\mscorsvw.exe;C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\ngen.exe;
07/08/10 15:30:26 DDSet_Status: Version Folder: C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\
07/08/10 15:30:26 DDSet_Status: File Version for C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\mscorsvc.dll is 2.0.50727.3053
07/08/10 15:30:26 DDSet_Status: File Version for C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\mscorsvw.exe is 2.0.50727.3053
07/08/10 15:30:26 DDSet_Status: File Version for C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\ngen.exe is 2.0.50727.3053
07/08/10 15:30:26 DDSet_Status: All required file versions matched: 2.0.50727.3053
07/08/10 15:30:26 DDSet_Status: Executing Command to stop ngen service: C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\ngen.exe queue scmstop
07/08/10 15:30:26 DDSet_Status: LANGID: 1033
07/08/10 15:30:26 DDSet_Warning: CreateProcess failed
MSI (s) (E4:94) [15:30:26:312]: User policy value 'DisableRollback' is 0
MSI (s) (E4:94) [15:30:26:312]: Machine policy value 'DisableRollback' is 0
Action ended 15:30:26: InstallExecute. Return value 3.

These kind of errors will cause entries to be written to the System event log. You can run eventvwr.exe and look for error messages with event source "SideBySide". This is generally caused by orphaned Visual C++ runtime assemblies left behind in the %windir%\WinSxS folder after uninstalling the previous build. In order to fix this issue, please follow the steps below:

Create a batch file that has the following commands and run it from a cmd prompt:

cd %SYSTEMROOT%\WinSXS
for /D %%i in (*vc80*) do rd %%i /s /q
del manifests\*vc80* /q
cd policies
for /D %%i in (*vc80*) do del %%i\* /q

Once it is executed, try installing .Net Framework 2.0.