Studio Issue or Code?

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 7 years and 2 weeks 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
branhama
Posts: 19
Last visit: Mon Jul 03, 2023 12:25 pm

Studio Issue or Code?

Post by branhama »

Hello all, not sure if this is a PS Studio issues or my I broke something. I am using the newest version PS Studio 2017 v 5.4.136.

Some information on my form:
It is to repair network folders/file permissions and dig into the structure rather than windows only going as far as it can see at the time and stopping. So when I locates a folder it did not have permissions to it take ownership applies new permission and then collects more child items it adds to its collection to do the same to. Kind of an automated way to dig in and get everything.

On to my issue:
I have everything working with the exception of one textblock I was using to output the number of folders / files modified so far. When I began it was working perfectly but I went in a played with the properties on the form elements to style it up and now it is not properly displaying the text within the block. I have even deleted that textblock/added it back, and even reset all the display properties of the entire form back. The only time the actual text is updated/displayed within the block is if my mouse moves over the form page. The text will continue to update if I move my mouse all around the form but if you stop so does the text updating.

Has anyone ever seen this before?
User avatar
branhama
Posts: 19
Last visit: Mon Jul 03, 2023 12:25 pm

Re: Studio Issue or Code?

Post by branhama »

Attached is my code if this helps.
Attachments
Repair-SharePermissions.Export.ps1
(206.03 KiB) Downloaded 190 times
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Studio Issue or Code?

Post by DevinL »

[TOPIC MOVED TO POWERSHELL GUIS FORUM BY MODERATOR]
DevinL
SAPIEN Technologies, Inc.
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Studio Issue or Code?

Post by DevinL »

At first read, this sounds to be a coding issue so I've moved this topic to the PowerShell GUI's forum in case anyone else can provide some help.

That being said, I've downloaded your provided code and I will look into it to make sure it's not a problem with PowerShell Studio.
DevinL
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Studio Issue or Code?

Post by jvierra »

This is usually caused be a form freeze which can be caused by many things, Most often it is caused by exceptions that are being thrown and not handled correctly.

It is curious that changing style elements would cause this. I suspect there was an underlying coding issue that changing the style brought to the surface.

Can you remember and describe what it was that you changed?
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Studio Issue or Code?

Post by DevinL »

Currently, I'm unable to verify this is an issue with PowerShell Studio.

I've subscribed to this topic and I'll keep a close eye in case things change.
DevinL
SAPIEN Technologies, Inc.
Alcha212
Posts: 9
Last visit: Fri Jan 25, 2019 6:52 pm

Re: Studio Issue or Code?

Post by Alcha212 »

I modified your original MainForm.psf and added a JobTracker to handle the functional code in the background.

I'm not sure this will actually fix the problem as I'm unable to test it against your system but it might help.

The only change to your code that's actually executed is instead of adding your output to the $tb_Activity control, it's output to the console so it's picked up by the job. Then, when the Update-JobTracker cmdlet is called, the output from your code is received and added to your $tb_Activity control.
MainForm.psf
(178.08 KiB) Downloaded 178 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Studio Issue or Code?

Post by jvierra »

I am curious to see David's analysis. With a quick but thorough look I see no coding issues that could account for this. Of course I don't have you data or system so this might be an issue in interacting with the system. I suspect that your change to the theme/style is not the cause of this.

My first suggestion is to check for error's and completions for your shell calls to "takeown". I suggest wrapping in a function and checking the $LASTEXITCODE and trapping for exceptions.

When you run this, are you running the PS! at a command prompt or just in the designer?
User avatar
branhama
Posts: 19
Last visit: Mon Jul 03, 2023 12:25 pm

Re: Studio Issue or Code?

Post by branhama »

After replacing the file I get the below errors in the console: I have just been running from the designer, but I did export to EXE and try with the same result. It seems all actions are completing properly.
  1. ERROR: Exception calling "AppendText" with "1" argument(s): "Object reference not set to an instance of an object."
  2. MainForm.psf (98, 3): ERROR: At Line: 98 char: 3
  3. ERROR: +             $tb_Activity.AppendText($Output)
  4. ERROR: +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. ERROR:     + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
  6. ERROR:     + FullyQualifiedErrorId : NullReferenceException
  7. ERROR:
  8. ERROR: Exception calling "AppendText" with "1" argument(s): "Object reference not set to an instance of an object."
  9. MainForm.psf (98, 3): ERROR: At Line: 98 char: 3
  10. ERROR: +             $tb_Activity.AppendText($Output)
  11. ERROR: +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  12. ERROR:     + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
  13. ERROR:     + FullyQualifiedErrorId : NullReferenceException
  14. ERROR:
  15. ERROR: You cannot call a method on a null-valued expression.
  16. ERROR:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
  17. ERROR:     + FullyQualifiedErrorId : InvokeMethodOnNull
  18. ERROR:     + PSComputerName        : localhost
  19. ERROR:
  20. ERROR: You cannot call a method on a null-valued expression.
  21. ERROR:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
  22. ERROR:     + FullyQualifiedErrorId : InvokeMethodOnNull
  23. ERROR:     + PSComputerName        : localhost
  24. ERROR:
  25. ERROR: Exception calling "AppendText" with "1" argument(s): "Object reference not set to an instance of an object."
  26. MainForm.psf (98, 3): ERROR: At Line: 98 char: 3
  27. ERROR: +             $tb_Activity.AppendText($Output)
  28. ERROR: +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  29. ERROR:     + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
  30. ERROR:     + FullyQualifiedErrorId : NullReferenceException
  31. ERROR:
  32. ERROR: You cannot call a method on a null-valued expression.
  33. ERROR:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
  34. ERROR:     + FullyQualifiedErrorId : InvokeMethodOnNull
  35. ERROR:     + PSComputerName        : localhost
  36. ERROR:
  37. ERROR: You cannot call a method on a null-valued expression.
  38. ERROR:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
  39. ERROR:     + FullyQualifiedErrorId : InvokeMethodOnNull
  40. ERROR:     + PSComputerName        : localhost
  41. ERROR:
  42. ERROR: The term 'Set-Objects' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
  43. ERROR: included, verify that the path is correct and try again.
  44. ERROR:     + CategoryInfo          : ObjectNotFound: (Set-Objects:String) [], CommandNotFoundException
  45. ERROR:     + FullyQualifiedErrorId : CommandNotFoundException
  46. ERROR:     + PSComputerName        : localhost
  47. ERROR:
  48. ERROR: The property 'Text' cannot be found on this object. Verify that the property exists and can be set.
  49. ERROR:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
  50. ERROR:     + FullyQualifiedErrorId : PropertyNotFound
  51. ERROR:     + PSComputerName        : localhost
  52. ERROR:
  53. ERROR: Exception calling "AppendText" with "1" argument(s): "Object reference not set to an instance of an object."
  54. MainForm.psf (98, 3): ERROR: At Line: 98 char: 3
  55. ERROR: +             $tb_Activity.AppendText($Output)
  56. ERROR: +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  57. ERROR:     + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
  58. ERROR:     + FullyQualifiedErrorId : NullReferenceException
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Studio Issue or Code?

Post by jvierra »

There is your issue. You have null objects for some reason. Try trapping on the null.
This topic is 7 years and 2 weeks 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