gpt4 book ai didi

entity-framework - Entity Framework ObjectStateManager.Detect Conflicts 中的空引用异常

转载 作者:行者123 更新时间:2023-12-02 04:59:19 24 4
gpt4 key购买 nike

我编写了一个 WCF 网络服务,它接收 XML 文件并将它们存储到数据库中。在“低负载”下一切正常,但在高负载下我遇到了一些意想不到的行为,到目前为止我还无法查明问题到底是什么。有人有什么建议吗?

这是我“有时”在日志中看到的异常 - 大约 10000 次中有 25 次:

Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.Objects.ObjectStateManager.DetectConflicts(IList`1 entries)
at System.Data.Objects.ObjectStateManager.DetectChanges()
at System.Data.Entity.Internal.InternalContext.GetStateEntry(Object entity)
at System.Data.Entity.DbContext.Entry(Object entity)
... rest of my stacktrace

我看到这种情况每隔一段时间就会发生一次,目前我正在研究这是否与并发性有关(其他一些线程可能在同一个实体上工作)。有人可以给我一些关于在哪里寻找的指示吗?

最佳答案

NullReferenceException 当您尝试使用值为 Nothing/null 的引用变量时发生。

When the value is Nothing/null for the reference variable, that means it is not actually holding a reference to an instance of any object that exists on the heap.

我不知道是什么问题,但我相信是线程问题。由于它适用于少数用户。当负载增加时,它可能会使用多个线程来提高性能。当线程异步执行时,出现此问题的可能性更大。!!

我可以提供的解决方案是自定义指定线程,并同步对象。可能会解决问题。

关于entity-framework - Entity Framework ObjectStateManager.Detect Conflicts 中的空引用异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18328979/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com