Using WMI to search in MicrosoftDNS_AType records cause generic failure

816 Views Asked by At

All day long trying to fix 0x80041001 error, but it's still shows that error. Turning firewall off, UAC off, didn't work. reseting WMI service, trying this, Running as administrator, still nothing changed! It's my code:

ManagementScope mgmtScope = new ManagementScope(@"\\.\Root\MicrosoftDNS", new ConnectionOptions() {  });
ManagementObjectCollection mgmtDNSRecords = new ManagementObjectSearcher(mgmtScope, new ObjectQuery(string.Format("SELECT * FROM MicrosoftDNS_AType WHERE OwnerName = '{0}.{1}'", strHostName, strDNSZone))).Get();
// Here the error accours:
if (mgmtDNSRecords.Count > 1)

Event viewer Error:

Id = {00000000-0000-0000-0000-000000000000}; ClientMachine = ARASHSERVER; User = ARASHSERVER\Administrator; ClientProcessId = 1004; Component = Unknown; Operation = Start IWbemServices::ExecQuery - Root\MicrosoftDNS : SELECT * FROM MicrosoftDNS_AType; ResultCode = 0x80041001; PossibleCause = Unknown

Running wbemtest.exe shows this error:

DNS_ERROR_ZONE_DOES_NOT_EXIST

Is there any fix for this problem?

1

There are 1 best solutions below

0
Arash Ghasemi Rad On

Running this query:

SELECT * FROM MicrosoftDNS_Zone

resulted a list that one zone was missing, I mean there were a zone in DNS manager (with no records) but didn't listed in query result. I deleted that zone and magically, problem solved!