KB3013 - Error: Failed to load designer
Scope
This article only applies to features of PowerShell Pro Tools for VS Code.
Problem
You receive the error message "Failed to load designer. Object reference not set to an instance of an object." when trying to use the 'Show Form Designer' button.
Symptoms
The WinForm Designer does open despite the error message, but it is an empty slate (screenshot not available) and not useable thus it will not be possible to design WinForms.
Root cause
This can occur if you have an existing PowerShell script that does not match the expectations of the VS Code extension.
Solution
Start over with a blank slate and then re-add your code.
- In a blank directory, use VS Code to create the base WinForms file (PowerShell script). Let's call it Winform-Example.ps1

- Click the 'Show Form Designer' button

- The Winform Designer UI should now show the useable UI.

- Click the save button 💾 in the Winform Designer UI and exit the Winform Designer UI.
- Important! Note that you will now have a total of 3 files in the empty directory that you created in Step 1 (shown below).

- Make a back-up of this directory.
- You should now have a clean solution to start re-adding your code into.