在实体框架code访问冲突访问SQL Server,实体、框架、冲突、code

2023-09-03 08:04:36 作者:想变得更好然后去拥抱你

我们已经遇到了我们的测试机器上的访问冲突,在实体框架code。我不知道这有可能是由于线程错误,或者如果它更可能是由于硬件问题。

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.

下面是部分调用堆栈:

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应用程序,使用实体框架4访问SQL Server 2008 R2。我读过有关访问冲突与EF和SQL Server CE ,但我们使用的是完整的SQL Server。我们不直接从我们的应用程序的任何原生code相互作用 - 无P / Invoke和COM互操作

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.

这仅发生过一次。我个人认为这是与机器,而不是应用程序的问题......在机器前BSOD'd几次。但有人问我寻找到它作为一个可能的错误。

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.

我会考虑设立DebugDiag资料赶上这一点,如果它再次发生。没有人有任何其他建议?

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

谢谢, 理查德

Thanks, Richard

推荐答案

我觉得你可能是对的,我猜想,有一个在同一个工作过程中的一些其他的code运行造成,导致一些内存损坏在这种错误。

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.