locked
Exception thrown when browser not installed RRS feed

  • Question

  • To open a url in default mail client, we use the following code :

    System.Diagnostics.Process.Start("http://www.live.com");

    Need to know the exception if there is no default browser set/installed.

     

    What is the difference if the url given is wrong like

    System.Diagnostics.Process.Start("ht://ww.live.com");

    What is the exact exception/message thrown in the above cases ??

    Please help.

    Thursday, September 24, 2009 12:48 AM

Answers

  • Hi,
    As we know, IE is installed as a component of Windows, so, we always have IE as default browser if user didn't uninstall it:)
    If we uninstall all browsers and then run your code, maybe the exception is still "An error occurred when opening the associated file", but it is worth trying.
    It is better to detect whether default browser exists before starting process, registry will help us to achieve it, but why we cannot use it?

    Thanks,
    Eric


    Please remember to mark helpful replies as answers and unmark them if they provide no help.
    • Marked as answer by eryang Monday, October 5, 2009 2:45 AM
    Friday, September 25, 2009 3:00 AM

All replies

  • Check the Process.Start documentation .

    In both cases, you'll receive Win32Exception.  [An error occurred when opening the associated file.]
    Reed Copsey, Jr. - http://reedcopsey.com
    • Proposed as answer by eryang Monday, September 28, 2009 7:41 AM
    Thursday, September 24, 2009 12:52 AM
  • Okay.
    But is there an exclusive error message for default browser not installed !!!!
    i want to show an error message only when default browser not found. (Not in favour of using registry)
    Thursday, September 24, 2009 5:06 AM
  • Hi,
    As we know, IE is installed as a component of Windows, so, we always have IE as default browser if user didn't uninstall it:)
    If we uninstall all browsers and then run your code, maybe the exception is still "An error occurred when opening the associated file", but it is worth trying.
    It is better to detect whether default browser exists before starting process, registry will help us to achieve it, but why we cannot use it?

    Thanks,
    Eric


    Please remember to mark helpful replies as answers and unmark them if they provide no help.
    • Marked as answer by eryang Monday, October 5, 2009 2:45 AM
    Friday, September 25, 2009 3:00 AM