Catch Commandline error
<p>I am trying to catch an error with an incorrect commandline parameter for the application of form </p>

<pre><code>Myapp.exe myFile.txt
</code></pre>

<p>The application however throws an "Unhandled exception - The path is not of legal form". </p>

<p>Below is my code and I am wondering why it does not show the message box as provided in the code? Thanks.</p>

<pre><code>String[] cmdlineArgs = Environment.GetCommandLineArgs();

if (cmdlineArgs.Length == 2)
{
    try
    {
        if (File.Exists(cmdlineArgs[1].ToString()))
            ConfigParameters.SetConfigParameters(cmdlineArgs[1].ToString());
        else
            {
                MessageBox.Show("Configuration file does not exist.Restarting...");
                Environment.Exit(1);
             }
     }
     catch (Exception ex)
     {

     }
</code></pre>
