'C# not existing element in ConcurrentDictionary causes BSOD in Release Compiled VErsion

I have this step:

        StepInfo[(int)this.currentState].Tasks[0].Start();

This runs in an async task, when I run this piece of code in Debug mode; the compiler gives me the exception that the key is not present. However when this is compiled (ASP.NET/C#) to release it results in a BSOD. Apart from the missing null check I dont quite understand how to handle errors like this as the BSOD does not give me any information in production systems.

Thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source