Invalid Class ManagementException when working with ManagementEventWatcher

423 Views Asked by At

I'm currently talking to another computer to see what events they have occurring. I have setup a Wql Event query like so below:

   Console.WriteLine("Polling...")
    Try
        Dim query As New WqlEventQuery("SELECT * FROM Lnl_AccessEvent")
        Dim accessEventWatcher = New ManagementEventWatcher("SELECT * FROM Lnl_AccessEvent")
        accessEventWatcher.Start()
        accessEventWatcher.WaitForNextEvent()
        Console.WriteLine("AccessEvent Occured.")

    Catch ex As Exception
        Console.WriteLine(ex.Message + " " + ex.StackTrace)
    End Try

On the ".Start()" line, I get an exception stating "Invalid class" and "ManagementException". I know the connection is working since before this instance I'm able to connect and get the basic info from the remote computer's WMI, like IP address. The only solutions I have found is that has to do with my target build being only x86, but now it's at AnyCPU and still has this issue.

What is causing this error?

0

There are 0 best solutions below