You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Search the existing issues, especially the pinned issues.
Exception report
### EnvironmentPSReadLine: 2.2.6PowerShell: 7.3.6OS: Microsoft Windows 10.0.19045BufferWidth: 200BufferHeight: 60Last 8 Keys: c l s Enter UpArrow UpArrow UpArrow Enter### ExceptionSystem.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.PowerShell.PSConsoleReadLine.ReadKey() at Microsoft.PowerShell.PSConsoleReadLine.InputLoop() at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken, Nullable`1 lastRunStatus)
I have a long running script that uses a FileSystemWatcher to monitor for changes to a file.
I had a bug where I didn't set the source identifier before registering for events, like so:
$watcher= [System.IO.FileSystemWatcher]::new($logPath,$logFilter)
Register-ObjectEvent$watcher Created -SourceIdentifier $createdEventIdentifier# Later on in function$createdEventIdentifier="Blah"
So I accidentally created a registeration without an event handler, then later on in a try/finally I did:
The end result was that when I kill my function (with Ctrl+C), I get into a NullReferenceException loop. I'm still able to input text, but it just repeatedly dumps the exceptions shown above.
If I run Get-EventSubscriber | Unregister-Event (yes I can still successfully run commands while it's in this error loop), then the erroring stops.
Expected behavior
Existing event subscriptions should not cause problems with ReadKey.
Actual behavior
ReadKey returns exceptions repeatedly until event registration is removed.
The text was updated successfully, but these errors were encountered:
Prerequisites
Exception report
Screenshot
N/A
Environment data
Steps to reproduce
I have a long running script that uses a FileSystemWatcher to monitor for changes to a file.
I had a bug where I didn't set the source identifier before registering for events, like so:
So I accidentally created a registeration without an event handler, then later on in a
try/finally
I did:So the unregisteration wouldn't do anything.
The end result was that when I kill my function (with Ctrl+C), I get into a NullReferenceException loop. I'm still able to input text, but it just repeatedly dumps the exceptions shown above.
If I run
Get-EventSubscriber | Unregister-Event
(yes I can still successfully run commands while it's in this error loop), then the erroring stops.Expected behavior
Existing event subscriptions should not cause problems with ReadKey.
Actual behavior
ReadKey returns exceptions repeatedly until event registration is removed.
The text was updated successfully, but these errors were encountered: