Given the following stack trace:
MESSAGE: Value cannot be null.Parameter name: key
SOURCE: mscorlib
TARGETSITE:
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.