2012-04-26 3 views
0

Windows Mobile 6.5 장치에서 CF 3.5로 실행되는 클라이언트 코드가 wcf 서비스를 호출하려고 시도 할 때 다음 코드가 발생합니다.WCF CFClientBase 직렬화 Stackoverflow 예외?

이상한 점은 VS에서 디버거로 실행 중이고 휴대 전화가 USB 케이블을 통해 PC에 연결되어있을 때 예외가 발생하지 않는다는 것입니다 ... 예상대로 호출이 작동합니다 .. 데이터가 그걸로되어 있습니다 ...

하지만 CFClientBase 코드는 다음과 같은 Stackoverflow Exception을 생성합니까?

이것은 모든 서비스 요청에서 발생합니다. 어떤 아이디어입니까?

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

일반적으로 stackoverflow 예외는 개체 그래프에 재귀 문제가있을 때 직렬화 중에 발생합니다 ('무한 조회'). 따라서 예를 들어 이 있으며 컬렉션은 Student입니다. 각 Student에는 Classes이 있고, 각 Class에는 Student 등의 컬렉션이 있습니다.

문제는 디버거에서 실행되지 않으므로 설명한 시나리오가 아닐 수도 있지만 큰 개체 그래프가 있고 전체 그래프를 직렬화하려고하는 유사한 시나리오가 있습니다. 나는 컴팩트 한 프레임 워크에 대해 많이 알지 못하지만, 스택이 더 작을 가능성이 있습니다 (따라서 스택 오버 플로우는 장치에 있지만 비주얼 스튜디오에는 없습니다).

어떤 요청을 하시겠습니까? 분명히 많은 데이터를 직렬화하고 있습니다. 얼마나 깊이 가나 요? 더 작은 데이터 세트로 요청을 처리 할 수 ​​있습니까?

먼저 훨씬 더 작은 요청을 시도하고 필요한 것보다 많은 데이터를 전선 (또는 '공중')으로 보내고 있는지 확인하십시오.

+0

모든 요청이 실패합니다 ... 4 개의 속성을 가진 클래스 9 인스턴스의 매우 작은 객체 그래프조차도 ... 아마 휴대폰에서 CF 프레임 워크를 다시로드하려고합니다. 하나 이상의 DLL이 잘못된 버전 또는 손상 –

+0

당신은 정확했다, SO 예외는 제한된 메모리 및 CF에 스택으로 인한 것입니다 ....내가 몰랐던 엔티티들을 XSD 워드 프로세서에 포함 시켰고 그 트릭을 수행했습니다! –

0

엔터티 형식이 WCF 서비스 인터페이스에 노출되었고 DataContract 또는 DataMember 특성으로 장식되어 있지 않은 것으로 밝혀졌습니다. 따라서 WCF 서비스가 네비게이션 속성을 통해 네임 스페이스의 모든 엔터티를 만 스칼라 속성에 대한 실체 그 자체 ...

클래스에 DataContract를 적용하고 DataMembers 난 후였다 내가 직렬화

감사를하지 않은 다른 유형을 모두 왼쪽으로 어떤 날 잡았어!

+0

'DataContract'와'DataMember'는 실제로 특정 객체와 속성이 직렬화되도록 보장하기 위해서만 사용 되었기 때문에 흥미 롭습니다. 꾸며진 것들을 제외하지 말아야합니다. –