How did I get this NullReferenceException error here right after the constructor?

后端 未结 6 1617
难免孤独
难免孤独 2020-12-04 21:22

I\'ve had an asp.net website running live on our intranet for a couple of weeks now. I just got an email from my application_error emailer method with an unhandled exception

6条回答
  •  忘掉有多难
    2020-12-04 22:11

    Another way I have seen this exception, unrelated to threading, is when serializing a Dictionary. In this case, it was empty, but I still got the NullReferenceException in the Insert() method on the deserialized instance.

    The simple change in my case was just to create a new instance after deserialization. I'm not sure whether the serialization just breaks the Dictionary, or if it is the types that the Dictionary is defined for.

    In my case the types were not serializable without serialization surrogates (and I had provided these), but maybe something in the Dictionary had a problem here. Again though, the Dictionary was empty and this still happened.

提交回复
热议问题