实体框架代码访问 SQL Server 时发生访问冲突

发布于 2024-11-26 09:41:48 字数 1705 浏览 1 评论 0 原文

我们在测试机器上的实体框架代码中遇到了访问冲突。我想知道这是否可能是由于线程错误造成的,或者更可能是由于硬件问题造成的。

下面是部分调用堆栈:

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at System.Data.Common.Internal.Materialization.CoordinatorFactory`1..ctor(Int32 depth, Int32 stateSlot, Expression hasData, Expression setKeys, Expression checkKeys, CoordinatorFactory[] nestedCoordinators, Expression element, Expression elementWithErrorHandling, Expression initializeCollection, RecordStateFactory[] recordStateFactories)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle._InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct& signature, RuntimeType declaringType)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, Object[] args)
   at System.Data.Common.Internal.Materialization.CoordinatorScratchpad.Compile()

这发生在 IIS 7 (Server 2008 R2 SP1) 上的 ASP.NET 应用程序中,使用 Entity Framework 4 访问 SQL Server 2008 R2。我读过EF 和 SQL Server 的访问冲突CE,但我们使用的是完整的 SQL Server。我们不直接与应用程序中的任何本机代码交互 - 没有 P/Invoke 或 COM 互操作。

这种事只发生过一次。就我个人而言,我认为这是机器的问题,而不是应用程序的问题......机器之前已经出现过几次蓝屏死机。但我被要求将其视为可能的错误进行调查。

如果再次发生这种情况,我将考虑设置 DebugDiag 来捕获此情况。有人还有其他建议吗?


谢谢,
理查德

We've encountered an access violation on our test machine, in Entity Framework code. I'm wondering if this could potentially be due to a threading bug, or if it's more likely due to hardware issues.

Here is a partial call stack:

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at System.Data.Common.Internal.Materialization.CoordinatorFactory`1..ctor(Int32 depth, Int32 stateSlot, Expression hasData, Expression setKeys, Expression checkKeys, CoordinatorFactory[] nestedCoordinators, Expression element, Expression elementWithErrorHandling, Expression initializeCollection, RecordStateFactory[] recordStateFactories)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle._InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct& signature, RuntimeType declaringType)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, Object[] args)
   at System.Data.Common.Internal.Materialization.CoordinatorScratchpad.Compile()

This happened in our ASP.NET app on IIS 7 (Server 2008 R2 SP1), using Entity Framework 4 to access SQL Server 2008 R2. I've read about access violations with EF and SQL Server CE, but we are using the full SQL Server. We aren't directly interacting with any native code from our app - no P/Invoke or COM interop.

This has only happened once. Personally I think it's a problem with the machine, not the application... the machine has BSOD'd a couple times before. But I was asked to look into it as a possible bug.

I'll look into setting up DebugDiag to catch this if it happens again. Does anyone have any other suggestions?

Thanks,
Richard

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

躲猫猫 2024-12-03 09:41:48

我认为您可能是对的,我猜测在同一个工作进程中运行了一些其他代码,导致了一些内存损坏,从而导致了此错误。

如果此工作进程中正在运行其他应用程序,您可能需要考虑将此应用程序分离到专用工作进程中。除此之外,我会将其归入“让我们留意”类别。

I think you're probably right, I would guess that there was some other code running in the same worker process which caused some memory corruption that resulted in this error.

If there are other applications running in this worker process, you might want to look at separating this application out into a dedicated worker. Other than that I would put it into the "lets just keep an eye out" category.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文