Wednesday, April 24, 2013

Retrieving the COM class factory for component with CLSID {CF4CC405-E2C5-4DDD-B3CE-5E7582D8C9FA} failed due to the following error: 800703fa

 

Once you use WMI services in your management code, you may suddenly receive following error message:

Retrieving the COM class factory for component with CLSID {CF4CC405-E2C5-4DDD-B3CE-5E7582D8C9FA} failed due to the following error: 800703fa.
   at System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(RuntimeType objectType)
   at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(Type serverType)
   at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(Type serverType, Object[] props, Boolean bNewObj)
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
   at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Management.MTAHelper.CreateInMTA(Type type)
   at System.Management.ManagementPath.CreateWbemPath(String path)
   at System.Management.ManagementPath..ctor(String path)
   at System.Management.ManagementClass..ctor(String path)

The reason is: the WMI performance object you want to access is not more properly registered or the registration is damaged (for example, due to lack of buffer space).

To ensure the cause of the error use the WMI diagnostic tool as mentioned in:

http://support.microsoft.com/kb/926640

The tool contains a VBS script WMIDiag.vbs.
IMPORTANT! Start the script using command line:

>cscript.exe WMIDiag.vbs

to receive proper tool output.
The output consist of (at least) two files: the report file WMIDIag-…-REPORT.TXT and the log file WMIDiag-….LOG. Both files contain date/time stamp and short machine info (OS Version etc.) in their names and located in %TEMP% folder of current user (i.e. C:\USERS\ADMINISTRATOR\APPDATA\LOCAL\TEMP if ran as administrator).

The report file contains mostly relevant information about the error’s cause, for example:

38819 09:29:32 (0) ** - Root/WMI, SystemConfig_CPU, 0x80041002 - (WBEM_E_NOT_FOUND) Object cannot be found.
38820 09:29:32 (0) **   MOF Registration: ''
38821 09:29:32 (0) ** - Root/WMI, SystemConfig_LogDisk, 0x80041002 - (WBEM_E_NOT_FOUND) Object cannot be found.
38822 09:29:32 (0) **   MOF Registration: ''
38823 09:29:32 (0) ** - Root/WMI, SystemConfig_Power, 0x80041002 - (WBEM_E_NOT_FOUND) Object cannot be found.
38824 09:29:32 (0) **   MOF Registration: ''
38825 09:29:32 (0) ** => When a WMI performance class is missing (i.e. 'Win32_PerfRawData_TermService_TerminalServices'), it is generally due to
38826 09:29:32 (0) **    a lack of buffer refresh of the WMI class provider exposing the WMI performance counters.
38827 09:29:32 (0) **    You can refresh the WMI class provider buffer with the following command:
38828 09:29:32 (0) **
38829 09:29:32 (0) **    i.e. 'WINMGMT.EXE /SYNCPERF'

The hint about refreshing the class provider requires following updates:

- the command is

WINMGMT.EXE /RESYNCPERF

- you have to restart your process accessing the WMI provider (i. e. if your ASP.NET application uses WMI provider, you have to restart the worker process or just launch iisreset).

Enjoy!