StackOverflowException序列化STE EF对象图 [英] StackOverflowException serializing STE EF object graph

查看:183
本文介绍了StackOverflowException序列化STE EF对象图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有.NET 4,WPF,WCF,EF 4,SQL 2008应用程序。我们的EF模型之一是高度关系的,在我描述的情况下可能并且可能确实包含周期。我被要求对现场的一个案例进行故障排除,这个STE EF模型的所有突然数据都会在WPF客户端中退出。仔细检查后,我发现IIS W3WP进程在尝试检索(序列化)STE EF对象图时崩溃了。我使用Debug Diagnostics来捕获崩溃。

We have a .NET 4, WPF, WCF, EF 4, SQL 2008 application. One of our EF models is highly relational and in the case I'm describing could and probably does contain cycles. 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. Upon closer examination, I found that the IIS W3WP process crashes when trying to retrieve (serialize) the STE EF object graph. I used Debug Diagnostics to capture the crash.

当我查看生成的崩溃报告时,我发现它是一个堆栈溢出异常(如何合适)。崩溃报告中的堆栈跟踪相当大,但堆栈顶部看起来像:

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) 

奇怪的是,当WCF服务托管在Visual Studio中并且我从开发环境运行时,序列化工作完美,我在客户端上获取数据。

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.

这可以通过IIS设置解决吗?为什么它适用于Visual Studio的开发IIS,而不适用于生产IIS?

Could this be resolved by IIS settings? Why would it work with Visual Studio's dev IIS, but not with the production IIS?

我不确定是什么导致了这个问题,或者为什么序列化器甚至是barfing?

I'm not sure what is causing this problem or why the serializer is even barfing?

我是否应该尝试使用另一种WCF序列化方法来使用STE EF4?

Should I try another means of WCF serialization w/ STE EF4?

任何输入都值得赞赏。

谢谢!

推荐答案

(默认情况下)IIS限制托管的堆栈大小线程为256 KB。我不知道开发Web服务器,但托管线程的默认堆栈大小是1 MB。此外,如果您在64位计算机上运行,​​则堆栈通常比32位计算机上的堆栈帧大。所以,如果您的开发盒是32位,您可能看不到您在生产中看到的内容。我在这里写了一些关于这一点 http://blogs.msdn.com/b/xmlteam/archive/2011/09/26/effective-xml-part -5-东西 - 去 - 真的,错OutOfMemoryException异常和-stackoverflowexception-抛起时,使用-xslcompiledtransform.aspx 。这是一个有点不同的上下文,但有关IIS,堆栈大小和帧大小的讨论仍然适用。

(By default) IIS limits stack size of managed threads to 256 KB. I don't know about dev web server but the default stack size for managed threads is 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. So, if your dev box is 32-bit you may not see what you see in production. 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. It is a bit different context but the discussion about IIS, stack sizes and frame sizes still applies.

这篇关于StackOverflowException序列化STE EF对象图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆