2012-06-14 40 views
0

我們有一個.NET 4,WPF,WCF,EF 4,SQL 2008應用程序。我們的EF模型之一是高度相關的,在我描述的情況下可能並可能包含循環。我被要求在現場處理一個案例,來自STE EF模型的突然數據在WPF客戶端中退出。仔細檢查後,我發現嘗試檢索(序列化)STE EF對象圖時,IIS W3WP進程崩潰。我使用調試診斷來捕獲崩潰。StackOverflowException序列化STE EF對象圖

當我看着生成的崩潰報告,我發現它是一個堆棧溢出異常(如何適當)。在事故報告中的堆棧跟蹤是相當大的,但堆棧的頂部看起來像:

System.Xml.XmlBaseWriter.StartElement(System.String ByRef, System.String, System.String, System.Xml.XmlDictionaryString) 
System.Xml.XmlBaseWriter.WriteStartElement(System.String, System.Xml.XmlDictionaryString, System.Xml.XmlDictionaryString) 
System.Runtime.Serialization.XmlWriterDelegator.WriteStartElement(System.String, System.Xml.XmlDictionaryString, System.Xml.XmlDictionaryString) 
DynamicClass.WriteXXXDataToXml(System.Runtime.Serialization.XmlWriterDelegator, System.Object, System.Runtime.Serialization.XmlObjectSerializerWriteContext, System.Runtime.Serialization.ClassDataContract) 
System.Runtime.Serialization.ClassDataContract.WriteXmlValue(System.Runtime.Serialization.XmlWriterDelegator, System.Object, System.Runtime.Serialization.XmlObjectSerializerWriteContext) 
System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithoutXsiType(System.Runtime.Serialization.DataContract, System.Runtime.Serialization.XmlWriterDelegator, System.Object, System.RuntimeTypeHandle) 
System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(System.Runtime.Serialization.XmlWriterDelegator, System.Object, Boolean, Boolean, Int32, System.RuntimeTypeHandle) 
System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerializeReference(System.Runtime.Serialization.XmlWriterDelegator, System.Object, Boolean, Boolean, Int32, System.RuntimeTypeHandle) 

是什麼讓特別奇怪的是,當WCF服務在Visual Studio託管,我從開發環境中運行,序列化完美地工作,並且我在客戶端上獲取數據。

這可以通過IIS設置來解決嗎?爲什麼它可以與Visual Studio的開發者IIS協同工作,但不能與生產IIS協同工作?

我不確定是什麼原因導致了這個問題,或者爲什麼串行器甚至是barfing?

我應該嘗試WCF系列化與STE EF4的另一種方法?

任何輸入表示讚賞。

謝謝!

回答

1

(默認情況下)IIS將託管線程的堆棧大小限制爲256 KB。我不知道有關開發Web服務器,但託管線程的默認堆棧大小爲1 MB。另外,如果您在64位機器上運行,堆棧通常比32位機器上的堆棧幀大。所以,如果你的開發箱是32位的,你可能看不到你在生產中看到的東西。我在這裏寫了一些關於http://blogs.msdn.com/b/xmlteam/archive/2011/09/26/effective-xml-part-5-something-went-really-wrong-outofmemoryexception-and-stackoverflowexception-thrown-when-using-xslcompiledtransform.aspx的信息。這是有點不同的上下文,但關於IIS,堆棧大小和幀大小的討論仍然適用。

+0

太棒了!感謝您的意見。我保證這是沿着這條線。有關如何更新IIS中堆棧大小的任何想法?本文http://blogs.msdn.com/b/tom/archive/2008/03/31/stack-sizes-in-iis-affects-asp-net.aspx描述瞭如何使用editbin.exe來完成。但是我們在生產環境中沒有這個exe。我可以在我的機器上更新w3wp.exe應用程序,但是我不能只在客戶機器上替換該文件,除非我擁有TrustedInstaller權限。有任何想法嗎? –