catch (InvalidCastException e) { if (e.Data == null) { throw; } else { // Take some action. } }