2011-07-25 122 views
0

我們遇到了我們的測試機上訪問衝突,在實體框架的代碼。我想知道這是否可能是由於線程錯誤,或者更可能是由於硬件問題。訪問衝突在實體框架代碼訪問SQL Server的

這裏是部分調用堆棧:

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。我讀過有關access violations with EF and SQL Server CE,但我們使用的是完整的SQL Server。我們不直接與我們的應用程序中的任何本機代碼進行交互 - 無需P/Invoke或COM互操作。

這僅發生過一次。就我個人而言,我認爲這是機器的問題,而不是應用程序......機器曾經有過幾次BSOD。但我被要求將其視爲一個可能的錯誤。

我會考慮設立DebugDiag資料趕上這一點,如果它再次發生。有沒有人有任何其他建議?


謝謝
理查德

回答

1

我想你可能是對的,我猜想,有在造成,導致此錯誤的內存損壞同一個工作進程中運行一些其他的代碼。

如果在此工作進程運行其他應用程序,你可能想看看分離出來這個應用到一個專門的工人。除此之外,我會把它放入「讓我們留意」類別。

+0

謝謝 - 好主意。在測試機上,它與其他一些測試應用程序一起運行在默認應用程序池中,但它們都應該是嚴格管理的代碼。無論如何,將它分成自己的應用程序池可能是一個好主意。我們也會做一些硬件診斷。 –