My mistake, my attempt with the snapshot was to show you the STA setting configuration that I have chosen.
I have also chosen the correct "Windows Forms Hosts" and it does not work, it fails.
Issues running in STA
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Issues running in STA
2 error scenarios that I have experienced with the STA depending on how the script is formulated.
1) Transcription fails ( an output that gets manipulated later)
Start-Transcript : This host does not support transcription.
Used to retrieve the output of a T-query on the SQL 2008r2 servers, some sql queries do not work with out-file and since servers are running ps v2 "4>" is not working with verbose switch (works fine in PS1 running in STA not in EXE)
2) the 2 previously mentioned Snapins are not recognized. (again works fine during the running of the PS1 in STA not in EXE)
FullyQualifiedErrorId
Microsoft.PowerShell.Commands.AddPSSnapinCommand
1) Transcription fails ( an output that gets manipulated later)
Start-Transcript : This host does not support transcription.
Used to retrieve the output of a T-query on the SQL 2008r2 servers, some sql queries do not work with out-file and since servers are running ps v2 "4>" is not working with verbose switch (works fine in PS1 running in STA not in EXE)
2) the 2 previously mentioned Snapins are not recognized. (again works fine during the running of the PS1 in STA not in EXE)
FullyQualifiedErrorId
Microsoft.PowerShell.Commands.AddPSSnapinCommand
Re: Issues running in STA
What do you mean the snap-ins are not recognized? What tis the exact error?
The extra redirectors are not available in V2.
Start-Transcript is not available with the Windows Host V2. It I sonly available in the CLI version of PowerShell as it is part of the PS2 host and not a module or CmdLet.
My suspicion is that the snap-ins cannot be made to work in the Windows Forms Host for many other reasons due to how the old snap-in were designed. They were only supported in the PS2 CLI at first.
The native mode for the snap-ins is MTA. If you start sqlps you will see that it requires MTA.
Forms only require STA if you use certain dialogs such as the folder dialog.
The extra redirectors are not available in V2.
Start-Transcript is not available with the Windows Host V2. It I sonly available in the CLI version of PowerShell as it is part of the PS2 host and not a module or CmdLet.
My suspicion is that the snap-ins cannot be made to work in the Windows Forms Host for many other reasons due to how the old snap-in were designed. They were only supported in the PS2 CLI at first.
The native mode for the snap-ins is MTA. If you start sqlps you will see that it requires MTA.
Forms only require STA if you use certain dialogs such as the folder dialog.
Re: Issues running in STA
Thank you for the information, I did not even think that transcription was not available in WHv2.
I am more leaning towards your suspicions regarding the snap-ins not working in Windows Forms Host.
I have not attempted to load the dll as you suggested, I will attempt that once I am back in the office later this evening and report to you then.
Regardless of the results, my extreme thanks for taking the time to respond.
I am more leaning towards your suspicions regarding the snap-ins not working in Windows Forms Host.
I have not attempted to load the dll as you suggested, I will attempt that once I am back in the office later this evening and report to you then.
Regardless of the results, my extreme thanks for taking the time to respond.
Re: Issues running in STA
Importing the dll in the proposed manner worked.
But since transcription is not possible when compiled, we have to continue running it as a script in STA mode.
But since transcription is not possible when compiled, we have to continue running it as a script in STA mode.