Ideally, you want to avoid the “stop working with the program” dialog, because, well, you want to avoid the “stop working with the program” condition for starters. If not, if you just want to register an error and let the program finish gracefully, the program really should finish gracefully.
If you exit the program using Environment.Exit(1) , you pretty much tell the operating system, “hey, I tried!”, Which is the opposite of a graceful finish. Try to exit with code 0 and see if it matters.
source share