0

当在 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 是否足以将这些类拉入架构?

4

2 回答 2

0

通常,当您的对象图中存在递归问题时,会在序列化期间发生 stackoverflow 异常 - “无限查找”。所以,例如,你有一个Class,它有一个集合Student; 每个Student都有一些Classes,每个Class都有一个集合Student,以此类推。

在调试器下运行时不会出现您的问题,因此它可能不是我所描述的场景,但是有一个类似的场景,您有一个大型对象图并试图序列化整个图。我对紧凑型框架了解不多,但堆栈可能更小(因此设备上的 stackoverflow 而不是 Visual Studio 中的)。

你提出什么样的要求?显然您正在序列化大量数据;它有多深?您能否使请求使用较小的数据集?

我建议先尝试一个小得多的请求,然后检查您是否通过网络(或“空中”)发送了比所需更多的数据。

于 2012-04-26T02:24:16.100 回答
0

事实证明,一个实体类型暴露给了 WCF 服务接口,并且它没有用任何 DataContract 或 DataMember 属性修饰,因此 WCF 服务显然通过实体本身的导航属性拉入了命名空间中的每个实体。 .

将 DataContract 应用于类,然后仅在标量属性上应用 DataMembers,这让我得到了我所追求的东西,并省略了我不想序列化的所有其他类型

谢谢 !

于 2012-04-26T18:47:49.087 回答