Skip to content
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

Reuse of Host for CreateRunspace OK? #2

Open
JustinGrote opened this issue Jun 2, 2023 · 0 comments
Open

Reuse of Host for CreateRunspace OK? #2

JustinGrote opened this issue Jun 2, 2023 · 0 comments

Comments

@JustinGrote
Copy link

JustinGrote commented Jun 2, 2023

Hi @PaulHigin,

_runspace = RunspaceFactory.CreateRunspace(
connectionInfo: _connectionInfo,
host: Host,
typeTable: TypeTable.LoadDefaultTypeFiles(),
applicationArguments: null,
name: Name);

Here in the createrunspace the cmdlet host is used, however https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.host.pshost?view=powershellsdk-7.2.0#remarks says There is a 1:1 relationship between the instance of the host class and the Runspace instance to which it is passed. In other words, it is not legal to pass the same instance of the host class to more than one call to CreateRunspace. (It is perfectly legal to call CreateRunspace more than once, as long as each call is supplied a unique instance of the host class.)

If you make multiple connections, doesn't this result in the same host instance being used for each remote runspace, thus violating the 1:1 relationship?

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

No branches or pull requests

1 participant