PowerShell Studio 2016, version 5.2.120, x64
Server 2012 R2
My button actions (on click) stop working after I create a build (exe)
However, if I export to file and run the script the buttons work just fine.
I've tried recreating the buttons, no change.
Any suggestions?
Buttons stop working after build
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
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 LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- Alexander Riedel
- Posts: 8488
- Last visit: Tue Apr 16, 2024 8:42 am
- Been upvoted: 37 times
Re: Buttons stop working after build
The critical pieces of information here would be:
1. What do the buttons do?
2. What error messages do you get, if any?
3. What packaging options do you use to build an executable?
4. All buttons don't work or just some?
1. What do the buttons do?
2. What error messages do you get, if any?
3. What packaging options do you use to build an executable?
4. All buttons don't work or just some?
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- lucassawyer
- Posts: 5
- Last visit: Wed Aug 16, 2017 3:53 pm
Re: Buttons stop working after build
Two that don't work:
One button clears form fields
Another button exports a file and opens another window
One that does work:
An image when clicked opens Chrome
No error messages.
I've only tried checking and unchecking STA.
One button clears form fields
Another button exports a file and opens another window
One that does work:
An image when clicked opens Chrome
No error messages.
I've only tried checking and unchecking STA.
- Alexander Riedel
- Posts: 8488
- Last visit: Tue Apr 16, 2024 8:42 am
- Been upvoted: 37 times
Re: Buttons stop working after build
In that case you will need to post some code. There is nothing obvious sticking out.
Generally problems like this involve scope problems, uninitialized variables or access denied issues (for files).
Maybe you can make a sample project with just the clear form fields handler and post that here.
Generally problems like this involve scope problems, uninitialized variables or access denied issues (for files).
Maybe you can make a sample project with just the clear form fields handler and post that here.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- lucassawyer
- Posts: 5
- Last visit: Wed Aug 16, 2017 3:53 pm
Re: Buttons stop working after build
I wasn't getting any errors. After moving the project to another system, I now get this error:
ERROR: Unable to find type [System.Windows.MessageBox]
However, the command in my script (see below) works from the same system when run in PowerShell ISE.
[System.Windows.MessageBox]::Show("Are you sure you want to clear the request?",'Clear Request','YesNo','Question')
We are right in the middle of having PowerShell upgraded on all workstations, perhaps this is a versioning issue.
ERROR: Unable to find type [System.Windows.MessageBox]
However, the command in my script (see below) works from the same system when run in PowerShell ISE.
[System.Windows.MessageBox]::Show("Are you sure you want to clear the request?",'Clear Request','YesNo','Question')
We are right in the middle of having PowerShell upgraded on all workstations, perhaps this is a versioning issue.
- lucassawyer
- Posts: 5
- Last visit: Wed Aug 16, 2017 3:53 pm
Re: Buttons stop working after build
Very bizarre. Some elements were created with "[System.Windows.MessageBox]", others "[System.Windows.Forms.MessageBox]"
I changed the buttons to the latter, and it all works now.
I changed the buttons to the latter, and it all works now.
- Alexander Riedel
- Posts: 8488
- Last visit: Tue Apr 16, 2024 8:42 am
- Been upvoted: 37 times
Re: Buttons stop working after build
Yeah, you have a .NET framework versioning issue. I am not sure about the exact versions at the moment,
but I think System.Windows.MessageBox exists since .NET framework 3.0 and System.Windows.Forms.MessageBox was present since 1.1
The Powershell version you are using to package and run your executable translates also to a specific .NET runtime.
See https://www.sapien.com/blog/2015/11/16/ ... equisites/
but I think System.Windows.MessageBox exists since .NET framework 3.0 and System.Windows.Forms.MessageBox was present since 1.1
The Powershell version you are using to package and run your executable translates also to a specific .NET runtime.
See https://www.sapien.com/blog/2015/11/16/ ... equisites/
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Buttons stop working after build
Also make sure you load the WinForms assembly beforehand. Not all hosts will pre-load the assembly.
Code: Select all
Add-Type -AssemblyName 'System.Windows.Forms'
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.