PS 5.1 Forms to PS 7

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
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.
This topic is 1 year and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
PGomersall
Posts: 131
Last visit: Thu Feb 15, 2024 12:14 pm

PS 5.1 Forms to PS 7

Post by PGomersall »

Has Sapien any recommendations for migrating GUI forms built for Windows Powershell to current Powershell 7?
Is there a list of things that will or will not work, say for example like: "folderbrowserdialogmodern" will not work in PS7. Maybe including steps on how to convert controls and cmdlets manually or by automation.
Regards,
Pete
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 11:13 am
Answers: 39
Been upvoted: 30 times

Re: PS 5.1 Forms to PS 7

Post by brittneyr »

To my knowledge, there is no major differences in WinForms from Windows PowerShell to PowerShell 7. In the initial release of PowerShell 7, there was many issues with WinForms, but those have since been resolved.
The FolderBrowserModernDialog was a control we made as a work around for WinForms using the older Folder browser dialog. It is no longer needed in PowerShell 7 as the FolderBrowserDialog was updated.

For more differences, please refer to the following article:
https://docs.microsoft.com/en-us/powers ... rshell-7.2
Brittney
SAPIEN Technologies, Inc.
User avatar
PGomersall
Posts: 131
Last visit: Thu Feb 15, 2024 12:14 pm

Re: PS 5.1 Forms to PS 7

Post by PGomersall »

Brittney,
I have started to do some testing on this. I have a forms template that I created using PS5.1 as a base. I saved this as a development item and swapped the PS version to 7. I have 7.2 installed.
The form had a folder browser dialog modern. I removed this and added the default folder browser dialog.
The form also has a ProgressBarOverlay. When I just try to preview the form I get a bunch of errors related to the ProgressBarOverlay control. So for testing I created new form based on your base Dialog Form template. I added the ProgressBarOverlay and docked it to bottom of form; when I preview I get the same errors.
Is this a form control that has been verified as working with PS7? If so not sure why I am getting the errors; if not why is it in PSS?
If I remove the ProgressBarOverlay and add a standard ProgressBar this will display without errors.
If I create a WinForms project in Visual Studio 2022 based on .Net6 I do not see the ProgressBarOverlay in the Toolbox.
Development\Testing done with:
Product: PowerShell Studio 2022 (64 Bit)
Build: v5.8.203
OS: Windows 10 Education (64 Bit)
Build: v10.0.22000.0
File paths have been changed below
ERROR: Add-Type: C:\path\PS GUI TemplatePS7.Preview.ps1:33
ERROR: Line |
ERROR: 33 | Add-Type -ReferencedAssemblies $Assemblies -TypeDefinition @"
ERROR: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: | (9,50): error CS1069: The type name 'Message' could not be found in the namespace 'System.Windows.Forms'. This type has
ERROR: | been forwarded to assembly 'System.Windows.Forms.Primitives, Version=6.0.2.0, Culture=neutral,
ERROR: | PublicKeyToken=b77a5c561934e089' Consider adding a reference to that assembly. protected override void
ERROR: | WndProc(ref Message m) ^
ERROR: Add-Type: C:\path\PS GUI TemplatePS7.Preview.ps1:33
ERROR: Line |
ERROR: 33 | Add-Type -ReferencedAssemblies $Assemblies -TypeDefinition @"
ERROR: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: | (11,18): error CS0012: The type 'Message' is defined in an assembly that is not referenced. You must add a reference to
ERROR: | assembly 'System.Windows.Forms.Primitives, Version=6.0.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
ERROR: | base.WndProc(ref m); ^
ERROR: Add-Type: C:\path\PS GUI TemplatePS7.Preview.ps1:33
ERROR: Line |
ERROR: 33 | Add-Type -ReferencedAssemblies $Assemblies -TypeDefinition @"
ERROR: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: | Cannot add type. Compilation errors occurred.
ERROR: New-Object: C:\path\PS GUI TemplatePS7.Preview.ps1:91
ERROR: Line |
ERROR: 91 | $pbProgress = New-Object 'SAPIENTypes.ProgressBarOverlay'
ERROR: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: | Cannot find type [SAPIENTypes.ProgressBarOverlay]: verify that the assembly containing this type is loaded.
ERROR: InvalidOperation: C:\path\PS GUI TemplatePS7.Preview.ps1:412
ERROR: Line |
ERROR: 412 | $pbProgress.Dock = 'Bottom'
ERROR: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: | The property 'Dock' cannot be found on this object. Verify that the property exists and can be set.
ERROR: InvalidOperation: C:\path\PS GUI TemplatePS7.Preview.ps1:413
ERROR: Line |
ERROR: 413 | $pbProgress.Location = New-Object System.Drawing.Point(0, 318)
ERROR: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: | The property 'Location' cannot be found on this object. Verify that the property exists and can be set.
ERROR: InvalidOperation: C:\path\PS GUI TemplatePS7.Preview.ps1:414
ERROR: Line |
ERROR: 414 | $pbProgress.Name = 'pbProgress'
ERROR: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: | The property 'Name' cannot be found on this object. Verify that the property exists and can be set.
ERROR: InvalidOperation: C:\path\PS GUI TemplatePS7.Preview.ps1:415
ERROR: Line |
ERROR: 415 | $pbProgress.Size = New-Object System.Drawing.Size(534, 23)
ERROR: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: | The property 'Size' cannot be found on this object. Verify that the property exists and can be set.
ERROR: InvalidOperation: C:\path\PS GUI TemplatePS7.Preview.ps1:416
ERROR: Line |
ERROR: 416 | $pbProgress.TabIndex = 22
ERROR: | ~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: | The property 'TabIndex' cannot be found on this object. Verify that the property exists and can be set.
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 11:13 am
Answers: 39
Been upvoted: 30 times

Re: PS 5.1 Forms to PS 7

Post by brittneyr »

The ProgressBarOverlay control was again a control added by us to extend the functionality of the standard ProgressBar control. It was updated upon the initially release of PowerShell 7, but appears to have issues with newer versions of V7.
I'll talk to the development team and get back to you.
Brittney
SAPIEN Technologies, Inc.
User avatar
PGomersall
Posts: 131
Last visit: Thu Feb 15, 2024 12:14 pm

Re: PS 5.1 Forms to PS 7

Post by PGomersall »

Thanks Brittney,
Is there a complete listing of Sapien enhanced Controls for both 5.1 and 7; it would be useful if available?
Pete
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 11:13 am
Answers: 39
Been upvoted: 30 times

Re: PS 5.1 Forms to PS 7

Post by brittneyr »

I have confirmed with the development team that those are the only two SAPIEN defined controls.
Brittney
SAPIEN Technologies, Inc.
This topic is 1 year and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked