Stop Unhandled Exception Alert

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 5 years and 2 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
Crazybyte
Posts: 2
Last visit: Thu Jan 24, 2019 4:38 am

Stop Unhandled Exception Alert

Post by Crazybyte »

Hi all,

I'm wondering if there is any way to totally suppress any Unhandled exception windows error except putting all the code in a try-catch statement.
I have a project with lots of lines and it work properly in any case, but all the times the program run, the followed alert appear. I really would like to avoid it.

Image --> screenshot link

How can I do?

Thanks in advance,
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Stop Unhandled Exception Alert

Post by jvierra »

What code is causing the exception? This exception looks more like a system error than a PowerShell exception. THe Net Framework is throwing an exception that cannot be trapped by PowerShell.
Crazybyte
Posts: 2
Last visit: Thu Jan 24, 2019 4:38 am

Re: Stop Unhandled Exception Alert

Post by Crazybyte »

I saw there was an 'exit' inside a function. This is the cause, I suppose I cannot use exit inside a form. Do you think I can use jobs to let that function run in background, so when the exit will be executed it will just terminate the job?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Stop Unhandled Exception Alert

Post by jvierra »

You can "Close" a form. An "exit" when compiled will throw an exception in the framework.
This topic is 5 years and 2 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