This error is coming only for the first time. From the 2nd run onwards the code is executed successfully. Surprisingly when I execute the code with the gap of 20-25 minutes the error is reproducible!
Please provide the solution urgently.
Thanks in Advance !
Please check the error details, sample C# code I am using.
Regards,
Sachin R.
================================================== ==
Expand|Select|Wrap|Line Numbers
- Error Details:
- ManagementException Error: Generic failure
- ManagementException Error code: Failed
- ManagementException ErrorInformation: System.Management.ManagementBaseObject
- ManagementException Error: at System.Management.ManagementException.ThrowWith
- ExtendedInfo(ManagementStatus errorCode)
- at System.Management.ManagementObjectEnumerator.MoveNext()
- at TestWMI.Class2.Main(String[] args)
C# Code:
Description: Using following C# code: Problematic code line is marked in bold tag.
Expand|Select|Wrap|Line Numbers
- try
- {
- string machineName = "dnsMachineName";
- System.Net.IPHostEntry iphe = System.Net.Dns.Resolve(machineName);
- string DnsServerName = iphe.HostName;
- string NameSpace = "\\\\" + DnsServerName + "\\root\\MicrosoftDNS";
- System.Management.ManagementScope EManagementScope = new System.Management.ManagementScope( NameSpace);
- EManagementScope.Connect();
- ManagementPath EZonePath = new ManagementPath("\\root\\MicrosoftDNS:MicrosoftDNS_Zone");
- ObjectGetOptions EGetOptions = new ObjectGetOptions();
- ManagementClass EManagementClass = new ManagementClass(EManagementScope , EZonePath, EGetOptions);
- ManagementObjectCollection mgmObjcoll = EManagementClass.GetInstances();
- foreach (ManagementObject MyZoneObj in EManagementClass.GetInstances()) {
- Console.WriteLine(MyZoneObj.Path);
- break;
- }
- }
- catch(ManagementException ex)
- {
- Console.WriteLine("ManagementException Error: "+ex.Message);
- Console.WriteLine("ManagementException Error code: "+ex.ErrorCode);
- Console.WriteLine("ManagementException ErrorInformation: "+ex.ErrorInformation);
- Console.WriteLine("ManagementException Error: "+ex.StackTrace);
- }