RunspacePool Open() fails with "Cannot add type. Compilation errors occurred" #23976
Unanswered
christophwille
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using Runspaces in two different flavors - one is via RunspaceFactory CreateRunspace
https://github.com/christophwille/pscore-playground/blob/19e271b94a7e6111c985c070697f39cb688856a7/ExO3onNet8LocalModule/ExO3PsLib/ExchangeOnlinePowerShellFactory.cs#L38-L92
and the other via RunspaceFactory CreateRunspacePool
https://github.com/christophwille/pscore-playground/blob/19e271b94a7e6111c985c070697f39cb688856a7/ExO3onNet8LocalModule/ExO3PsLib/ExchangeOnlinePowerShellFactory.cs#L94-L124
Here is the headscratcher: the first variant works a-ok (opening the runspace, then executing the command inside it, creating a PowerShell on top), whereas the second (a pool with a startup script instead so I can have multiple warm Runspaces managed for me) crashes with an exception on Open() - before getting to the exact exception, I'd like to point out that via christophwille/pscore-playground#8 (comment) I was able to debug that the script actually ran to completion before the exception happend:
The very special part about is problem is that the Exchange PowerShell module I am loading actually works in version 3.4 in all variations of ConnectScript.ps I wrote, whereas none worked in 3.5.
Questions: can anyone come up with a hypothesis why when the script has run the DoOpenHelper() method would complain? Secondly, as I am no PowerShell internals person, how could I get a more meaningful error from PowerShell on this or actually even debug into it?
Beta Was this translation helpful? Give feedback.
All reactions