【问题标题】:Access violation in Entity Framework code accessing SQL Server访问 SQL Server 的实体框架代码中的访问冲突
【发布时间】:2011-07-25 18:34:01
【问题描述】:

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

这是一个部分调用堆栈:

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。我读过access violations with EF and SQL Server CE,但我们使用的是完整的SQL Server。我们没有直接与应用程序中的任何本机代码交互 - 没有 P/Invoke 或 COM 互操作。

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

如果它再次发生,我会考虑设置 DebugDiag 以捕捉它。有人有其他建议吗?


谢谢,
理查德

【问题讨论】:

    标签: .net entity-framework debugging crash


    【解决方案1】:

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

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

    【讨论】:

    • 谢谢 - 好主意。在测试机器上,它与其他一些测试应用程序在默认应用程序池中运行,但它们都应该是严格管理的代码。无论如何,将其分离到自己的应用程序池中可能是个好主意。我们也会做一些硬件诊断。
    【解决方案2】:
    猜你喜欢
    • 1970-01-01
    • 2011-02-19
    • 2011-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-10
    相关资源
    最近更新 更多