There are a few other questions that touch this subject, but none seem to address it (or then, they are too complex for me to understand them...)
I have a:
Private MCDevices As New Dictionary(Of IPAddress, MCDeviceInfo)
In this Dictionary, the IPAddress are the keys (obviously), and the MCDeviceInfo are Classes defined elsewhere. So it's basically a Dictionnary(Of IPAddress, Class).
I want do a For ... Next loop through the MCDevices Dictionary, and in that loop, I change the contents of the MCDeviceInfo Classes: in the loop, I change the values of the KVP, but no IPAddress is added, changed nor deleted within the loop in any way, and I double-checked that.
For Each kvp As KeyValuePair(Of IPAddress, MCDeviceInfo) In MCDevices
' Some code changing the contents of the MCDeviceInfo but not the IPAddress
Next
Still, reaching the Next, I get:
**System.InvalidIperationException:** 'Collection was modified; enumeration operation may not continue'.
The conditional may here is very optimistic, as the code just stops there...
Is there a way to handle this? Why can't I change the Values as long as the Keys are untouched?