WPF and WinForms app do not appear when running in Visual Studio

WPF and WinForms app do not appear when running in Visual Studio

Product: PowerShell Pro Tools for Visual Studio
Version: Any
Issue:
When running a PowerShell WPF or WinForm script, the script will start but it will not show the window at all. 
Resolution:
1. When running a WPF form, ensure that the file that is active is the xaml.ps1 file and not the xaml file. Since the XAML file does not contain executable code, you cannot start it. Run the PS1 file instead. 
2. When running a WPF form, you may need to load the WPF framework in order to start the form. Add: [System.Reflection.Assembly]::LoadWithPartialName("PresentationFramework") as the first line in the script. 
2. When running either a WPF or WinForm script, the script may start but no form will appear. Sometimes, the form will appear behind Visual Studio. Minimize Visual Studio to see if the form is running behind the editor. 
    • Related Articles

    • "Failed to attach the PowerShell debug engine debugger" error when attempting to run scripts in Visual Studio

      Version: PowerShell Tools for Visual Studio 5.x Issue: When attempting to run scripts in Visual Studio, an error will be shown when attempting to start the debugger. This can happen both by pressing F5 with a PowerShell script open or by clicking the ...
    • KB3007 - Resetting PowerShell Pro Tools (Visual Studio)

      Scope This article applies to Visual Studio 2017, 2019 and 2022 (Community, Professional and Enterprise) with the PowerShell Tools for Visual Studio [2002] extension. Problem The PowerShell Tools for Visual Studio extension will not load or A ...
    • KB3004 - Visual Studio Code missing "Package EXE" button

      Symptom The 'Package EXE' button is missing from Visual Studio Code (with the PowerShell Pro Tools extension1 installed). Scenario #1 You don't have a PowerShell script file (*.ps1) file loaded in VS Code Solution Load a PowerShellscript file (*.ps1) ...
    • KB3006 - WPF Item is missing in VS2022

      Symptom The option to add a WPF Item (i.e. XAML) to a PowerShell Script Project in Visual Studio 2022 is no longer available. Cause At some point in August 2023, Microsoft introduced breaking changes into Visual Studio 2022 around WPF handling. As a ...
    • KB3005 - Troubleshooting License Issues

      Purpose The purpose of this article is to explain in technical detail how to workaround when the license for PowerShell Pro Tools won't install (figure shows how an Ironman Software license file should appear in a text viewer) Affected Products ...