Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - System.Management.ManagementException 'generic failure' during remote WMI query

Reply
 
Old 05-11-2009   #1 (permalink)
Malcolm McCaffery


 
 

System.Management.ManagementException 'generic failure' during remote WMI query

Hi There I'm using a C# Visual Studio 2008 / .NET 3.5 / Windows Vista SP1 to
write a utility that queries windows event log remotely.

When querying a certain remote PC it works fine returning a couple of
hundred events then suddenly an exception on this line.

foreach (ManagementObject oReturn in oReturnCollection) (see below for
context)

It appears to be the same event log entry being read that causes this,
because I am always getting the same event log entry before the exception.

Is there anything I can do to detect the cause of this exception, or trap it
(and continue the foreach loop?)

The exception detail is

System.Management.ManagementException was unhandled
Message="Generic failure "
Source="System.Management"
StackTrace:
at
System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus
errorCode)
at
System.Management.ManagementObjectCollection.ManagementObjectEnumerator.MoveNext()
at EventAnalyzer.Program.Main(String[] args) in
C:\Users\mccafma\Documents\Visual Studio
2008\Projects\EventAnalyzer\EventAnalyzer\Program.cs:line 387
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:


using System.Management;

RemoteComputer = "remotepc01"

bool display = true;
ManagementScope oMs;
ObjectQuery oQuery;
ManagementObjectSearcher oSearcher;
ManagementObjectCollection oReturnCollection;

oMs=new ManagementScope(@"\\" + RemoteComputer +
@"\root\cimv2", oConn);

Query = "Select * from Win32_NTLogEvent Where (Logfile =
'System' OR Logfile='Application')";

//get system events
oQuery = new ObjectQuery(Query);

Console.WriteLine("Executing \"" + Query + "\" on " +
oMs.Path.ToString());
Console.WriteLine();
//Execute the query
oSearcher = new ManagementObjectSearcher(oMs, oQuery);

//Get the results
oReturnCollection = oSearcher.Get();

//loop through found drives and write out info

foreach (ManagementObject oReturn in oReturnCollection)
{
// process items here
}

regards,

Malcolm.


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Disk Management Query Error Vista General
startup failure & system restore 'WINRE' query Vista performance & maintenance
Generic Failure on DFS WMI providers PowerShell
Get-WmiObject : Generic failure PowerShell
WMI DNS and 'Generic failure' PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46