-1

I want to suppress the c# windows form message box errors. Like in my application there is a config file for the printer configuration, so when there is no printer attached or there's an issue with the port it gives an error. I want to suppress that built in windows error. Is there a way of doing this? Any help would be appreciated. Thanks in advance. :)

  • 2
    Look at the code where you are reading from config file, you will have to handle this case just after that – Vivek Nuna Oct 13 '16 at 08:22
  • May be a duplicate of this: http://stackoverflow.com/questions/12532812/how-to-suppress-a-dialog-box-displayed-by-code-that-i-cant-change – LordWilmore Oct 13 '16 at 08:22
  • 1
    Maybe you should write your program to gracefully handle error conditions? It's a bit like saying _"Oh this heart rate monitor is really kinda kewl but it makes a rather annoying racket when the patient heart stops and I'm trying to watch Holby City "_ –  Oct 13 '16 at 08:31

1 Answers1

0

Being forms you could add a try catch on Application.Run:

        try
        {
            Application.Run(new Form1());
        }
        catch (Exception ex)
        {
            //MessageBox.Show(ex.Message);
        }

Or would recommend handling the event as per winforms-global-exception-handling

Community
  • 1
  • 1