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
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Thu Jan 17, 2019 5:59 pm

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: 14335
Joined: Tue May 22, 2007 9:57 am
Contact:

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

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: 14335
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Stop Unhandled Exception Alert

Post by jvierra »

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

Locked