简体   繁体   English

StackOverflowException序列化STE EF对象图

[英]StackOverflowException serializing STE EF object graph

We have a .NET 4, WPF, WCF, EF 4, SQL 2008 application. 我们有一个.NET 4,WPF,WCF,EF 4,SQL 2008应用程序。 One of our EF models is highly relational and in the case I'm describing could and probably does contain cycles. 我们的EF模型之一是高度相关的,在我正在描述的情况下,它可能包含周期。 I've been asked to troubleshoot a case in the field where all of a sudden data from this STE EF model quit showing up in the WPF client. 我被要求对现场的一种情况进行故障排除,这种情况是该STE EF模型突然退出的数据不再显示在WPF客户端中。 Upon closer examination, I found that the IIS W3WP process crashes when trying to retrieve (serialize) the STE EF object graph. 仔细检查后,我发现IIS W3WP进程在尝试检索(序列化)STE EF对象图时崩溃。 I used Debug Diagnostics to capture the crash. 我使用了Debug Diagnostics来捕获崩溃。

When I looked at the generated crash report, I discovered it was a stack overflow exception (how appropriate). 当我查看生成的崩溃报告时,我发现这是一个堆栈溢出异常(如何适当)。 The stack trace in the crash report is rather large, but the top of the stack looks something like: 崩溃报告中的堆栈跟踪相当大,但是堆栈顶部看起来像:

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) 

What makes exceptionally odd is that when the WCF service is hosted in Visual Studio and I run from the dev environment, the serialization works perfectly, and I get data on the client. 异常奇怪的是,当WCF服务托管在Visual Studio中并且在开发环境中运行时,序列化工作正常,并且我在客户端上获取数据。

Could this be resolved by IIS settings? 可以通过IIS设置解决吗? Why would it work with Visual Studio's dev IIS, but not with the production IIS? 为什么它可以与Visual Studio的dev IIS一起使用,而不与生产IIS一起使用?

I'm not sure what is causing this problem or why the serializer is even barfing? 我不确定是什么原因导致此问题,或者不确定为什么序列化程序甚至发动攻击?

Should I try another means of WCF serialization w/ STE EF4? 我应该尝试使用STE EF4进行WCF序列化的另一种方法吗?

Any input is appreciated. 任何输入表示赞赏。

Thanks! 谢谢!

(By default) IIS limits stack size of managed threads to 256 KB. (默认情况下)IIS将托管线程的堆栈大小限制为256 KB。 I don't know about dev web server but the default stack size for managed threads is 1 MB. 我不了解开发Web服务器,但托管线程的默认堆栈大小为1 MB。 In addition if you are running on a 64-bit machine stack frames are in general bigger than stack frames on a 32-bit machine. 另外,如果您在64位计算机上运行,​​则堆栈框架通常比32位计算机上的堆栈框架大。 So, if your dev box is 32-bit you may not see what you see in production. 因此,如果您的开发箱是32位的,则可能看不到生产中的内容。 I wrote a little bit about this here 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 . 我在这里http://blogs.msdn.com/b/xmlteam/archive/2011/09/26/effective-xml-part-5-something-went-really-wrong-outofmemoryexception-and-使用xslcompiledtransform.aspx时抛出stackoverflowexception It is a bit different context but the discussion about IIS, stack sizes and frame sizes still applies. 上下文略有不同,但是有关IIS,堆栈大小和框架大小的讨论仍然适用。

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

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