GUI project going grey, (Not Responding)
Posted: Sun Feb 07, 2016 3:47 pm
Hey there!
I am working on my first GUI project with Powershell Studio 2015, and have run into an odd issue.
Let me preface this with saying, I have read the articles about creating responsive forms and have used that information extensively on my project.
Most of the functions that I have created in this script are stored in the globals.ps1 file, and the events on my forms call those functions.
I can run the entire application without fail from the IDE (i.e., clicking Run/Debug), but when I export the application to an executable, it fails at a very particular point. Essentially the form works in 3 high-level steps, each fired by a button control:
1) Query and select a target against which work will be performed
2) Collect credentials, authenticate against and open session to host
3) Do work
The first two steps work pretty well with good consistency, but the button to fire step 3 will cause the application to fail every single time.
I have tried adjusting the tasks that are actually carried out by the button (in the project, called $main_button_run) to more and more menial tasks in order to test and debug, but it fails regardless of what I configure it to do. Is there something i am missing here?
Currently the code that is fired by a button click is as follows:
The function being called is stored in globals.ps1, and does the following:
The Add-RemoteJobTracker is a just a version of SAPIEN's Add-JobTracker that has been modified to use invoke-command in order to execute remote tasks, as well as to close the PSSessions when they are no longerneeded.
Is there something stupid here that I am not seeing?
I am working on my first GUI project with Powershell Studio 2015, and have run into an odd issue.
Let me preface this with saying, I have read the articles about creating responsive forms and have used that information extensively on my project.
Most of the functions that I have created in this script are stored in the globals.ps1 file, and the events on my forms call those functions.
I can run the entire application without fail from the IDE (i.e., clicking Run/Debug), but when I export the application to an executable, it fails at a very particular point. Essentially the form works in 3 high-level steps, each fired by a button control:
1) Query and select a target against which work will be performed
2) Collect credentials, authenticate against and open session to host
3) Do work
The first two steps work pretty well with good consistency, but the button to fire step 3 will cause the application to fail every single time.
I have tried adjusting the tasks that are actually carried out by the button (in the project, called $main_button_run) to more and more menial tasks in order to test and debug, but it fails regardless of what I configure it to do. Is there something i am missing here?
Currently the code that is fired by a button click is as follows:
- $main_button_run_Click={
- Write-Debug 'run clicked'
- $main_label_elapsed_static.Visible = $false
- $main_label_elapsed.Visible = $false
- #DiagRun
- LogRun-Setup
- }
- function LogRun-Setup
- {
- # Checks for presence of security group, creates/attaches if necessary.
- # A PS session is opened for the LogRun task, the root working path is
- # set and the start time is stored. A folder is created at the root
- # working path.
- Write-Debug 'Logrun-Setup init'
- $main_label_status.text = "Creating security group..."
- Write-Debug 'CheckSG'
- CheckSG
- $main_label_status.text = "Opening session..."
- $global:jobList = @()
- $global:startDTM = (Get-Date)
- $global:RootPath = "c:\WorkSpacesLogs\"
- $main_label_status.text = "Creating working directory..."
- Write-Debug 'adding rootpath job'
- Add-RemoteJobTracker -Name "CreateRootPath" -JobScript `
- {
- $global:RootPath = $args[0]
- Remove-Item $global:RootPath -recurse -Force -ErrorAction SilentlyContinue | out-null
- New-Item $global:RootPath -type directory -force | out-null
- } -ArgumentList $global:RootPath -CompletedScript `
- {
- Write-Debug "RootpathCreated"
- }
- Wait-Job -Name "CreateRootPath"
- Write-Debug "LogRun-Setup Complete"
- $main_label_status.text = "Gathering Workspace Logs..."
- }
Is there something stupid here that I am not seeing?