在Windows Mobile 6.5设备上的CF 3.5中运行的客户端代码尝试调用我们的wcf服务之前发生以下错误...甚至在它进行调用之前。
奇怪的是,当在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 :(得分:0)
通常,当您在对象图中出现递归问题时,序列化期间会发生堆栈溢出异常 - “无限查找”。因此,例如,您有一个Class
,其集合为Student
;每个Student
都有一些Classes
,每个Class
都有一个Student
的集合,依此类推。
你的问题不会在调试器下运行,所以它可能不是我所描述的场景,但是有一个类似的场景,你有一个大的对象图,并试图序列化整个图。我对Compact框架知之甚少,但是堆栈可能更小(因此设备上的堆栈溢出而不是Visual Studio中的堆栈溢出)。
你在做什么样的要求?显然你正在序列化大量数据;它有多深?您是否能够使用较小的数据集来处理请求?
我建议先尝试一个小得多的请求,然后检查你是否通过网络(或“空中”)发送的数据超过了所需数据。
答案 1 :(得分:0)
事实证明,实体类型已暴露给WCF服务接口,并且未使用任何DataContract或DataMember属性进行修饰,因此WCF服务显然通过实体上的导航属性拉入命名空间中的每个实体本身...
将DataContract应用于类,然后仅在标量属性上的DataMembers使我得到了我所追求的并省去了我不想序列化的所有其他类型
谢谢!