2012-04-26 61 views
0

以下錯誤發生whenthe在窗戶CF 3.5上運行的客戶端代碼的移動設備6.5試圖撥打我們的WCF服務......它甚至能做出呼叫前。WCF CFClientBase序列化Stackoverflow異常?

奇怪的是,當在VS中的調試器下運行並且手機通過USB電纜連接到PC時,異常不會發生......該調用按預期工作......數據來回傳送應該是...

但是,當它自己運行時,CFClientBase代碼生成以下Stackoverflow異常?

這發生在所有的服務電話,而不僅僅是一個...任何想法?

StackOverflowException 

    at System.Reflection.CustomAttribute.GetObject() 
    at System.Reflection.CustomAttribute.CheckConsistencyAndCreateArray(CustomAttribute caItem, Type caType) 
    at System.Reflection.CustomAttribute.GetCustomAttributes(MemberInfo member, Type caType, Boolean inherit) 
    at System.Reflection.CustomAttribute.GetCustomAttributes(Type type, Type caType, Boolean inherit) 
    at System.RuntimeType.GetCustomAttributes(Boolean inherit) 
    at System.Xml.Serialization.TypeAttributes..ctor(ICustomAttributeProvider prov) 
    at System.Xml.Serialization.TypeAttributes..ctor(ICustomAttributeProvider prov, XmlAttributes xmlAtts) 

at System.Xml.Serialization.XmlSerializationReflector.AddType(Type type, Boolean encoded, String defaultNS, Boolean genericNullableArg) 
    at System.Xml.Serialization.XmlSerializationReflector.FindType(Type type, Boolean encoded, Boolean genericNullableArg, String defaultNamespace) 
    at System.Xml.Serialization.XmlSerializationReflector.FindType(Type type, Boolean encoded, String defaultNamespace) 
    at System.Xml.Serialization.XmlSerializationReflector.ResolveLiteralTypeUsingDeclaredType(Type memberType, String defaultNS, LogicalType& type, LogicalType& elementType, Boolean& isArray) 
    at System.Xml.Serialization.XmlSerializationReflector.ResolveLiteralType(String attrDataType, Type attrType, Type memberType, String defaultNS, Boolean& isArray, LogicalType& type, LogicalType& elementType) 
    at System.Xml.Serialization.XmlSerializationReflector.ReflectXmlElementAttributes(Type memberType, LogicalMemberValue memberValue, String memberName, LiteralAttributes attrProv, AccessorCollection memberAccessors, String defaultName, String defaultNS, Type& serializingType, Boolean& shouldBeOrdered) 
    at System.Xml.Serialization.XmlSerializationReflector.ReflectLiteralMemberValue(Type memberType, String memberName, LiteralAttributes attrProv, String defaultName, String defaultNS, IEntityFinder memberFinder, Boolean canRead, Boolean canWrite, Boolean& shouldBeOrdered) 
    at System.Xml.Serialization.XmlSerializationReflector.ReflectMemberValue(Type memberType, ICustomAttributeProvider attrProv, String defaultName, String defaultNS, IEntityFinder memberFinder, Fetcher fetcher, Fixup fixup, MemberValueCollection members, Boolean encoded, Boolean canRead, Boolean canWrite, Byte& specialType, Boolean& shouldBeOrdered) 
    at System.Xml.Serialization.XmlSerializationReflector.addComplexTypeMemberHelper(Type type, MemberInfo member, Boolean encoded, String defaultNS, Boolean& shouldBeOrdered, IEntityFinder choiceFinder, MemberValueCollection members, String typeNS, String defaultMemberNS, Int32& sequenceId) 
    at System.Xml.Serialization.XmlSerializationReflector.AddComplexType(Type type, TypeAttributes attrs, String typeName, String typeNS, Boolean typeIsNullable, Boolean encoded, String defaultNS, Boolean genericNullableArg) 
    at System.Xml.Serialization.XmlSerializationReflector.AddType(Type type, Boolean encoded, String defaultNS, Boolean genericNullableArg) 
    at System.Xml.Serialization.XmlSerializationReflector.FindType(Type type, Boolean encoded, Boolean genericNullableArg, String defaultNamespace) 
    at System.Xml.Serialization.XmlSerializationReflector.FindType(Type type, Boolean encoded, String defaultNamespace) 
    at System.Xml.Serialization.XmlSerializationReflector.ReflectIncludedTypes() 
    at System.Xml.Serialization.XmlSerializer..ctor(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, String defaultNamespace) 
    at Microsoft.Tools.ServiceModel.CFClientBase`1.CFContractSerializer.createSerializer(XmlQualifiedName wrapper) 
    at Microsoft.Tools.ServiceModel.CFClientBase`1.CFContractSerializer..ctor(CFContractSerializerInfo info) 
    at Microsoft.Tools.ServiceModel.CFClientBase`1.GetContractSerializer(CFContractSerializerInfo info) 
    at Microsoft.Tools.ServiceModel.CFClientBase`1.Invoke[TREQUEST,TRESPONSE](CFInvokeInfo info, LogIntoServerRequest request) 
    at WCFService.WOService.WOServiceClient.LogIntoServer(LogIntoServerRequest request) 
    at WCFService.WOService.WOServiceClient.LogIntoServer(SmartPhoneLoginCredentials creds) 
    at RescoMobileApp.Common.Classes.loginClass.LogIntoServer() 

編輯

看來,即使我使用DTO的跨線連載......不知怎的,我的EF實體類正在架構中的發送?

由於某些原因,這些類型試圖構建服務調用時?

如何讓這些課程脫離模式?如果有實體名稱空間的引用足以讓WCF將這些類拉入模式中?

回答

0

通常情況下,如果在對象圖中存在遞歸問題(無限查找),則會在序列化期間發生堆棧溢出異常。因此,舉例來說,你有一個Class,其中有Student集合;每個Student有一些Classes,每個Class有一個集合Student,等等永遠。

您的問題不會出現在調試器下運行,所以它可能不是我所描述的情況,但有一個類似的場景,你有一個很大的對象圖,並試圖序列全圖。我不知道很多關於緊湊型框架,但它很可能是堆棧較小(因此在設備上的計算器,但不能在Visual Studio)。

你在做什麼樣的要求?顯然你正在序列化大量的數據;它有多深?您是否能夠使用較小的數據集來處理請求?

我建議先嚐試一個小得多的請求,然後檢查是否發送的數據超過了所需要的數據(或「空氣」)。

+0

每個請求都失敗......即使是一個具有4個屬性的類的9個實例的非常小的對象圖....我將嘗試重新加載手機上的CF框架,也許一個或多個DLL是版本錯誤或損壞 – 2012-04-26 13:10:39

+0

你是正確的,SO的例外是由於有限的內存和堆棧上的CF ....擺脫了我沒有意識到的實體被包含在xsd文檔中,並且做到了這一點! – 2012-04-26 18:49:33

0

事實證明,一個實體類型暴露給WCF服務接口,並且它沒有用任何DataContract或DataMember屬性修飾,所以WCF服務顯然通過導航屬性在名稱空間中拉入了名稱空間中的每個實體實體本身...

應用DataContract的類,然後數據成員只對標性能得到了我什麼,我是後,離開了所有其他類型,我不想系列化

致謝!

+0

這很有趣,因爲'DataContract'和'DataMember'確實只用於確保某些對象和屬性被序列化,而不是排除那些被裝飾的對象和屬性。 – 2012-04-26 22:13:00