Error message when you use the System.Management.ObjectGetOptions enumeration in Visual C# .NET or in Visual C# 2005: "Argument '3': cannot convert from 'System.TimeSpan' to 'System.Management.ObjectGetOptions'" (839285)



The information in this article applies to:

  • Microsoft Visual C# .NET (2003)
  • Microsoft Visual C# .NET (2002)
  • Microsoft Visual C# 2005, Express Edition

SYMPTOMS

When you use the System.Management.ObjectGetOptions enumeration in the ManagementClass class constructor in Microsoft Visual C# .NET and in Microsoft Visual C# 2005, you may receive the following compiler error message:
Argument '3': cannot convert from 'System.TimeSpan' to 'System.Management.ObjectGetOptions'

CAUSE

This issue occurs if the ManagementClass class constructor is passed to the System.Management.ObjectGetOptions.InfiniteTimeout field as a third parameter. The following code is an example:
ManagementClass objClass = new  ManagementClass("","",System.Management.ObjectGetOptions.INFINITE);

RESOLUTION

The ManagementClass class constructor is used as follows:
ManagementClass objClass = new ManagementClass("","",new ObjectGetOptions());
If you want an uninitialized ManagementClass object, use the default class contractor as follows:
ManagementClass objClass = new ManagementClass();

Modification Type:MajorLast Reviewed:1/16/2006
Keywords:kbCompiler kbprb KB839285 kbAudDeveloper kbAudITPRO