-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
Description
I've created a System.Management.ManagementEventWatcher instance that I'm using to monitor for creation of new power plans. But, if a power plan exists that does not have a name, calling Start throws System.IO.FileNotFoundException.
Reproduction Steps
Export the standard Balanced power plan, delete it, reimport, but do not give it a name.
powercfg /export %TEMP%\Balanced.pow 381b4222-f694-41f0-9685-ff5bb260df2e
powercfg /delete 381b4222-f694-41f0-9685-ff5bb260df2e
powercfg /import %TEMP%\Balanced.pow 381b4222-f694-41f0-9685-ff5bb260df2e
Then, run this code:
ManagementEventWatcher watcherCreate = new ManagementEventWatcher (
new ManagementScope ("\root\cimv2\power"),
new WqlEventQuery (
"__InstanceCreationEvent",
new TimeSpan (0, 0, 5),
"TargetInstance isa "Win32_PowerPlan""
)
);
watcherCreate.Start (); // BOOM!
Expected behavior
Start the watcher without throwing an exception. i.e. should not care if a power plan has a name or not.
Actual behavior
Throws System.IO.FileNotFoundException
Regression?
Dunno. Probably not.
Known Workarounds
None
Configuration
.NET 10.0.3
Windows 10 19045.6937
x64
Other information
No response