简体   繁体   English

实体框架代码访问SQL Server中的访问冲突

[英]Access violation in Entity Framework code accessing SQL Server

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. 这是在IIS 7(Server 2008 R2 SP1)上的ASP.NET应用程序中发生的,使用实体框架4访问SQL Server 2008 R2。 I've read about access violations with EF and SQL Server CE , but we are using the full SQL Server. 我已经阅读了有关EF和SQL Server CE的访问冲突的信息 ,但是我们正在使用完整的SQL Server。 We aren't directly interacting with any native code from our app - no P/Invoke or COM interop. 我们没有直接与应用程序中的任何本机代码进行交互-没有P / Invoke或COM互操作。

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. 我个人认为这是机器的问题,而不是应用程序的问题。。。机器之前曾几次进行过BSOD检查。 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. 如果再次发生,我将研究设置DebugDiag来捕获它。 Does anyone have any other suggestions? 还有其他建议吗?


Thanks, 谢谢,
Richard 理查德

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. 除此之外,我将其放入“让我们保持警惕”类别。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM