Why is there unreachable code here?
<p>I am writing a c# app and want to output error messages to either the console or a messagebox (Depending on the app type: enum AppTypeChoice { Console, Windows } ), and also control wether the app keeps running or not ( bool StopOnError ). </p>

<p>I came up with this method that will check all the criteria, but I'm getting an "unreachable code detected" warning. I can't see why!</p>

<p>Here is the whole method (Brace yourselves for some hobbyist code!)</p>

<pre>
<code>
    public void OutputError(string message)
    {
        string standardMessage = "Something went WRONG!. [ But I'm not telling you what! ]";
        string defaultMsgBoxTitle = "Aaaaarrrggggggggggg!!!!!";
        string dosBoxOutput = "\n\n*** " + defaultMsgBoxTitle + " *** \n\n Message was: '" + message + "'\n\n";
        AppTypeChoice appType = DataDefs.AppType;
        DebugLevelChoice level = DataDefs.DebugLevel;

        // Decide how much info we should give out here...
        if (level != DebugLevelChoice.None)
        {
            // Give some info....
            if (appType == AppTypeChoice.Windows)
                MessageBox.Show(message, defaultMsgBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            else
                Console.WriteLine(dosBoxOutput);
        }
        else
        {
            // Be very secretive...
            if (appType == AppTypeChoice.Windows)
                MessageBox.Show(standardMessage, defaultMsgBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            else
                Console.WriteLine(standardMessage);
        }

        // Decide if app falls over or not..
        if (DataDefs.StopOnError == true)
            Environment.Exit(0); // UNREACHABLE CODE HERE
    }
</code>
</pre>

<p>Also, while I have your attention, to get the app type, I'm just using a constant at the top of the file (ie. AppTypeChoice.Console in a Console app etc) - is there a better way of doing this (i mean finding out in code if it is a DOS or Windows app)? </p>

<p>Also, I noticed that I can use a messagebox with a fully-qualified path in a Console app...How bad is is to do that ( I mean, will I get tarred and feathered when other developers see it?!)</p>

<p>Thanks for your help</p>
