Skip to content

System.InvalidOperationException from Invoke-ScriptAnalyzer command when debugging PSES #959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rkeithhill opened this issue Apr 1, 2018 · 2 comments

Comments

@rkeithhill
Copy link
Contributor

I've been debugging other issues in PSES and I'm seeing multiple instances of this exception. Can this be safely ignored or is there a problem here:

image

image

This was using Windows PowerShell 5.1 on Windows 10 FCU.

Copied over from PSES - PowerShell/PowerShellEditorServices#572

@bergmeister
Copy link
Collaborator

bergmeister commented Apr 1, 2018

@rkeithhill There is a possibility that it is related to #902, but #902 happens much more below the stack that you show, it has the same exception type but different message. Current research suggests that #902 seems to be due a thread safety bug in PowerShell itself (PSSA spawns a new thread for each rule btw).
Can you give a more detailed stack trace and example scriptdefinition input to reproduce?
Are you calling Invoke-ScriptAnalyzer -ScriptDefinition multiple times in the same PowerShell session or do you always start from a fresh session/runspace? Are you calling into PSSA multiple times with overlapping calls?

@bergmeister
Copy link
Collaborator

bergmeister commented Apr 11, 2018

Bang. I had something similar today when attaching the debugger to it when debugging #966 . The exception gets swallowed as one can see but having an empty catch block seems to be rather a code smell...
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants