Для всех, кто попал сюда, я нашел случай, когда это возможно (если это можно обнаружить только в отладчике).VS2013 Обновление 4.
Сломано:
try
{
// do something
}
catch (WebException ex) // <- both variables are named 'ex'
{
Logger.Log("Error while tried to do something. Error: " + ex.Message);
}
catch (Exception ex) // <- this 'ex' is null
{
Logger.Log("Error while tried to do something. Error: " + ex.Message);
}
Решение состоит в том, чтобы по-разному называть переменные исключения.
Исправлено:
try
{
// do something
}
catch (WebException webEx) // <- all good in the hood
{
Logger.Log("Error while tried to do something. Error: " + webEx.Message); // <-
}
catch (Exception ex) // <- this 'ex' correctly contains the exception
{
Logger.Log("Error while tried to do something. Error: " + ex.Message);
}