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.
Locked
Crazybyte
Posts: 2
Joined: Thu Jan 17, 2019 5:59 pm

Stop Unhandled Exception Alert

Post by Crazybyte » Thu Jan 17, 2019 10:11 am

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,

User avatar
jvierra
Posts: 13807
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Stop Unhandled Exception Alert

Post by jvierra » Thu Jan 17, 2019 10:30 am

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
Joined: Thu Jan 17, 2019 5:59 pm

Re: Stop Unhandled Exception Alert

Post by Crazybyte » Thu Jan 17, 2019 10:58 am

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?

User avatar
jvierra
Posts: 13807
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Stop Unhandled Exception Alert

Post by jvierra » Thu Jan 17, 2019 11:31 am

You can "Close" a form. An "exit" when compiled will throw an exception in the framework.

Locked