The issue is that when I alter the Connections dictionary, it invalidates the enumerable (because I could have altered the keys). By calling ToArray, I'm making an independent list of the keys that remains valid.