How to: Fix Provider Load Failure Error

.NET Framework 3.5

WMI clients can get a Provider Load Failure error when they attempt to use functionality implemented in a WMI provider that leverages the WMI Provider Extensions infrastructure.

The cause might be an improperly-registered dynamic-link library (DLL). During installation of the .NET Framework 3.5 (prior to SP1), the DLL named System.Management.Instrumentation.dll is not properly registered.

To perform the registration, run the Regasm.exe tool providing the full path to the DLL as the only argument. The following procedure provides step-by-step directions to properly register System.Management.Instrumentation.dll.

Register System.Management.Instrumentation.dll

  1. Click Start, and select All Programs.

  2. Click Microsoft Visual Studio 2008 and select Visual Studio Tools.

  3. On operating systems before Windows Vista, click Microsoft Visual Studio 2008 Command Prompt to open a command prompt window. On Windows Vista, right-click Microsoft Visual Studio 2008 Command Prompt and select Run as Administrator to open an elevated command prompt window.

  4. At the command prompt, type "regasm %systemdrive%\program files\reference assemblies\microsoft\framework\v3.5\system.management.instrumentation.dll" and press ENTER.

  5. Check for the message, Types registered successfully. To verify that the registration has been corrected, you can run the WSH script below. It should output System.Management.Instrumentation for .NET Framework 3.5 is already registered.

Example

The following sample script shows how you can use the WMI registry provider from a WSH script to automate correcting the registration of System.Management.Instrumentation.dll. Use this script as a starting point to create your own script to ensure that this registration is correct before installing your WMI providers that leverage the WMI Provider Extensions infrastructure. Information on altering the script to target multiple and remote computers is available from the TechNet Script Center.

strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\default") 
' Obtain an object of the class 

Set objShare = objWMIService.Get("StdRegProv")

' Obtain an InParameters object specific
' to the method.
Set objInParam = objShare.Methods_("GetStringValue").inParameters.SpawnInstance_()


' Add the input parameters.
objInParam.Properties_.Item("hDefKey") =  2147483648
objInParam.Properties_.Item("sSubKeyName") =  "CLSID\{54D8502C-527D-43F7-A506-A9DA075E229C}\Inprocserver32"
objInParam.Properties_.Item("sValueName") =  "Assembly"

' Execute the method and obtain the return status.
' The OutParameters object in objOutParams
' is created by the provider.
Set objOutParams = objWMIService.ExecMethod("StdRegProv", "GetStringValue", objInParam)

' List OutParams
If objOutParams.ReturnValue = 0 Then
WScript.Echo "Out Parameters: "
WScript.Echo "ReturnValue: " & objOutParams.ReturnValue
WScript.Echo "sValue: " & objOutParams.sValue
Else
WScript.Echo "ReturnValue: " & objOutParams.ReturnValue
WScript.Echo "Not able to retrieve Registration of System.Management.Instrumentation. Check if .NET Framework 3.5 is installed"
WScript.Quit
End If

If (objOutParams.sValue = "System.Management.Instrumentation, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") Then

WScript.Echo "Set String Values"
' Obtain an InParameters object specific
' to the method.
Set objInParam = objShare.Methods_("SetStringValue"). _
    inParameters.SpawnInstance_()


' Add the input parameters.
objInParam.Properties_.Item("hDefKey") =  2147483648
objInParam.Properties_.Item("sSubKeyName") =  "CLSID\{54D8502C-527D-43F7-A506-A9DA075E229C}\Inprocserver32"
objInParam.Properties_.Item("sValue") =  "System.Management.Instrumentation, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
objInParam.Properties_.Item("sValueName") =  "Assembly"

' Execute the method and obtain the return status.
' The OutParameters object in objOutParams
' is created by the provider.
Set objOutParams = objWMIService.ExecMethod("StdRegProv", "SetStringValue", objInParam)

' List OutParams
If objOutParams.ReturnValue = 0 Then
WScript.Echo "Out Parameters: "
WScript.Echo "ReturnValue: " & objOutParams.ReturnValue
Else
WScript.Echo "ReturnValue: " & objOutParams.ReturnValue
WScript.Echo "Not able to register"
WScript.Quit
End If

WScript.Echo "Creating New Key"

' Obtain an InParameters object specific' to the method.
Set objInParam = objShare.Methods_("CreateKey"). _
    inParameters.SpawnInstance_()
' Add the input parameters.
objInParam.Properties_.Item("hDefKey") =   2147483648
objInParam.Properties_.Item("sSubKeyName") =  "CLSID\{54D8502C-527D-43F7-A506-A9DA075E229C}\Inprocserver32\3.5.0.0"

' Execute the method and obtain the return status.
' The OutParameters object in objOutParams
' is created by the provider.
Set objOutParams = objWMIService.ExecMethod("StdRegProv", "CreateKey", objInParam)

' List OutParams
If objOutParams.ReturnValue = 0 Then
WScript.Echo "Out Parameters: "
WScript.Echo "ReturnValue: " & objOutParams.ReturnValue
Else
WScript.Echo "ReturnValue: " & objOutParams.ReturnValue
WScript.Echo "Not able to Register"
WScript.Quit
End If


WScript.Echo "Creating String Values"
' Obtain an InParameters object specific
' to the method.
Set objInParam = objShare.Methods_("SetStringValue"). _
    inParameters.SpawnInstance_()


' Add the input parameters.
objInParam.Properties_.Item("hDefKey") =  2147483648
objInParam.Properties_.Item("sSubKeyName") =  "CLSID\{54D8502C-527D-43F7-A506-A9DA075E229C}\Inprocserver32\3.5.0.0"
objInParam.Properties_.Item("sValue") =  "System.Management.Instrumentation, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
objInParam.Properties_.Item("sValueName") =  "Assembly"

' Execute the method and obtain the return status.
' The OutParameters object in objOutParams
' is created by the provider.
Set objOutParams = objWMIService.ExecMethod("StdRegProv", "SetStringValue", objInParam)

' List OutParams
If objOutParams.ReturnValue = 0 Then
WScript.Echo "Out Parameters: "
WScript.Echo "ReturnValue: " & objOutParams.ReturnValue
Else
WScript.Echo "ReturnValue: " & objOutParams.ReturnValue
WScript.Echo "Not able to Register"
WScript.Quit
End If


' Add the input parameters.
objInParam.Properties_.Item("hDefKey") =  2147483648
objInParam.Properties_.Item("sSubKeyName") =  "CLSID\{54D8502C-527D-43F7-A506-A9DA075E229C}\Inprocserver32\3.5.0.0"
objInParam.Properties_.Item("sValue") =  "System.Management.Instrumentation.ManagedCommonProvider"
objInParam.Properties_.Item("sValueName") =  "Class"

' Execute the method and obtain the return status.
' The OutParameters object in objOutParams
' is created by the provider.
Set objOutParams = objWMIService.ExecMethod("StdRegProv", "SetStringValue", objInParam)

' List OutParams
If objOutParams.ReturnValue = 0 Then
Wscript.Echo "Out Parameters: "
WScript.Echo "ReturnValue: " & objOutParams.ReturnValue
Else
WScript.Echo "ReturnValue: " & objOutParams.ReturnValue
WScript.Echo "Not able to Register"
WScript.Quit
End If

' Add the input parameters.
objInParam.Properties_.Item("hDefKey") =  2147483648
objInParam.Properties_.Item("sSubKeyName") =  "CLSID\{54D8502C-527D-43F7-A506-A9DA075E229C}\Inprocserver32\3.5.0.0"
objInParam.Properties_.Item("sValue") =  "v2.0.50727"
objInParam.Properties_.Item("sValueName") =  "RuntimeVersion"

' Execute the method and obtain the return status.
' The OutParameters object in objOutParams
' is created by the provider.
Set objOutParams = objWMIService.ExecMethod("StdRegProv", "SetStringValue", objInParam)

' List OutParams
If objOutParams.ReturnValue = 0 Then
WScript.Echo "Out Parameters: "
WScript.Echo "ReturnValue: " & objOutParams.ReturnValue
Else
WScript.Echo "ReturnValue: " & objOutParams.ReturnValue
WScript.Echo "Not able to Register"
WScript.Quit
End If
WScript.Echo "Registration of System.Management.Instrumentation was successful"

Else
WScript.Echo "System.Management.Instrumentation for .NET Framework 3.5 is already registered."
End If

See Also

Send comments about this topic to Microsoft.

Copyright © 2007 by Microsoft Corporation. All rights reserved.

Show: