Question: I've noticed an oddity in developing my C# application with Visual Studio 2010. In some cases, a NullReferenceException doesn't get thrown when, as far as I know, it should be. Instead the application continues as normal but gets stuck such that I can't close it normally and am forced to kill it.

As an example, consider the following:

```
public class MyControl : UserControl
{
    private SomeClass myObj;
    public MyControl()
    {
        Bar();
        myObj = new SomeClass();
    }

    public void Bar()
    {
        myObj.SomeProperty = 5; // myObj is null here but no exception gets thrown
    }
}

```

Instead of an exception getting thrown when `myObj.SomeProperty = 5;` is executed, the code jumps out of the function back to where the constructor for `MyControl` was called by a parent Form. I can get NullReferenceExceptions (as well as other exceptions) caught by the debugger in other instances, just not ones like this.

Should a NullReferenceException be thrown here or am I misunderstanding something about C# and/or .NET?

Answer: 
In VS, go to Debug->Exceptions->Common Language Runtime Exceptions and check Thrown, then try again. It will show you if you have exception caught somewhere else.
**Reason**

Somewhere along the call stack, a try/catch block is wrapping this exception and handling it "gracefully."

**How to See Handled Exceptions**

If you *really* want to check to see if an exception is being *thrown*, regardless of whether or not it is *user-unhandled*, you'll need to enable the `Thrown` exception checkbox for `Common Language Runtime Exceptions` under the `Debug > Exceptions...` menu.

**Repeat**

Enable the thrown exception setting, try again, and you'll get a notification about the exception.

**Other Possibilities**

Your code may be out of date.