0

I recently started learning C# and found quickly that one exception was not being thrown when I ran my project. The tutorial I was watching mentioned that exceptions work differently in the Release configuration then they do in the Debug configuration so I figured I must be running with the Release configuration.

I found an article on Microsoft's site that indicates how to switch configurations, however I must be missing something in the instructions because I still cannot figure out how to switch settings.

I'm using Visual Studio Express 2010 for C#. Could someone tell me why the exception below is not being thrown and how to fix it?

Here is the code I'm using:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ReallySimpleLifeCounter
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            _testLabel.Content = "Working";
            throw new Exception(); //not being thrown
        }
    }
}
robhasacamera
  • 2,967
  • 2
  • 28
  • 41
  • 2
    I also began learning C# with Visual Studio Express, I can assure you that exceptions are thrown when debugging. Maybe post some of your code? – JMK Jan 22 '13 at 00:56
  • 2
    Exceptions are thrown in both modes. There must be something else you are doing wrong. – Andrew Savinykh Jan 22 '13 at 00:57
  • Did you change the Visual Studio version to 2010 at the top of that page? If so, look in your 'Options' under 'Debugging>General'. – Nashibukasan Jan 22 '13 at 00:59
  • "exceptions are only thrown in Debug mode" is very far from truth (would not be nice to magically have code working just by compiling in release?)... Showing code (or at least providing link to the source of information) would help with getting an answer. – Alexei Levenkov Jan 22 '13 at 00:59
  • How do you know exceptions aren't being thrown? How are you trying to detect them (logs, crashing, in the debugger, etc)? – Mike Parkhill Jan 22 '13 at 01:00
  • "exceptions are not being thrown when I build my project". Exceptions are raised when you *run* a project, not when you *build* it. Or are talking about build *errors*? Do spend some more time learning and reading, hard to ask a question when you don't know enough to properly ask it. And never forget to post a snippet, everybody here understands code. – Hans Passant Jan 22 '13 at 01:08
  • @JMK I added some example code. – robhasacamera Jan 22 '13 at 01:11
  • @HansPassant Clarified the question. – robhasacamera Jan 22 '13 at 01:30
  • 3
    http://stackoverflow.com/questions/4933958/vs2010-does-not-show-unhandled-exception-message-in-a-winforms-application-on-a/4934010#4934010 – Hans Passant Jan 22 '13 at 01:33
  • @HansPassant That was the issue, thank you for the link. If you post it as the answer I will accept. – robhasacamera Jan 22 '13 at 02:00

1 Answers1

0

You can set the mode using the configuration manager, it is usually hot keyed F5.

Make sure you have the toolbar 'Standard' selected from there you can select the mode to run the Build {Debug, Release}