How is this Dictionary exception possible?

后端 未结 6 1193
遥遥无期
遥遥无期 2021-01-12 02:28

Given the following stack trace:

MESSAGE: Value cannot be null.Parameter name: key  
SOURCE: mscorlib  
TARGETSITE:          


        
6条回答
  •  旧时难觅i
    2021-01-12 02:43

    I've had this problem happen frequently because I made the mistake of allowing multiple threads to access the same dictionary. Make sure that this is not the case, because Dictionary is not thread-safe.

    (Incidentally, your method can be greatly simplified. Dictionary is already an IEnumerable>. You should be able to just do ToArray on one.

提交回复
热议问题