Nov 17, 2011 at 2:34 PM
Edited Nov 18, 2011 at 8:18 AM
Hi there, I have a custom toolwindow in Visual Studio 2010 that contains a custom PowerShell host.
I would like to know if/how ShowUI can work in a VS context. I'm using the latest ShowUI version, 1.3.
When I run the following code in PowerGui, it shows that the apartment state is STA, shows the label, and shows "Done" after I close the label window:
New-Label "Hello World" -Show
When I run the same code in NuGet Package manager, it shows MTA and ShowUI tells me that it needs STA. So I changed my custom host from MTA to STA.
Now when I run the same code in my custom host in Visual Studio, it also shows STA, but it shows no visible window and produces no errors. Instead I get output:
Loading module from path 'C:\Users\vincenth\Documents\WindowsPowerShell\Modules\ShowUI\ShowUI.psm1'.
Loading module from path 'C:\Users\vincenth\Documents\WindowsPowerShell\Modules\ShowUI\GeneratedAssemblies\ShowUI.CLR4.0.30319.225.dll'.
Importing cmdlet 'New-DependencyObject'.
Importing cmdlet 'New-DispatcherSynchronizationContext'.
Importing alias 'XmlDataProvider'.
Using -AsJob to create a thread does not work either.
Basically I have 2 questions
- Can ShowUI work in a VS2010 context?
- If so, what does ShowUI require from the PowerShell host?
Any example code of a custom PowerShell host where ShowUI works would be great.