开发者

"The resource MultipleIdDefinition was not found" on deserialization on Windows Phone 7

I suddenly started getting this from my Windows Phone 7 app. I don't know what changed in the data I was deserialization that would have caused this. Any idea what it means?

System.Runtime.Serialization.SerializationException occurred
  Message=The resource MultipleIdDefinition was not found in System.Runtime.Serialization
  StackTrace:
       at System.Runtime.Serialization.ReferencedObjectCache.Add(String id, Object referencedObject)
       at System.Runtime.Serialization.XmlObjectSerializerReadContext.AddNewObjectWithId(String id, Object obj, Boolean isReference)
       at System.Runtime.Serialization.XmlObjectSerializerReadContext.AddNewObject(Object obj, Boolean isReference)
       at System.Runtime.Serialization.XmlFormatReader.InvokeBeforeDeserialization(ClassDataContract classContract, XmlObjectSerializerReadContext context)
       at System.Runtime.Serialization.XmlFormatReader.InitializeCallStack(DataContract clContract, XmlReaderDelegator xmlReaderDelegator, XmlObjectSerializerReadContext xmlObjContext, XmlDictionaryString[] memberNamesColl, XmlDictionaryString[] memberNamespacesColl)
       at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
       at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)
       at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, DataContract& dataContract)
       at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 id, RuntimeTypeHandle declaredTypeHandle, String name, String ns)
       at System.Runtime.Serialization.XmlFormatReader.InternalDeserialize(Object value, Type type, String name, String ns, XmlObjectSerializerReadContext context, XmlReaderDelegator xmlRea开发者_Python百科der)
       at System.Runtime.Serialization.XmlFormatReader.ReadValue(Type type, String name, String ns, XmlObjectSerializerReadContext context, XmlReaderDelegator xmlReader)
       at System.Runtime.Serialization.XmlFormatReader.ReadCollectionItem(CollectionDataContract collectionContract, Type itemType, String itemName, String itemNs, XmlObjectSerializerReadContext context, XmlReaderDelegator xmlReader)
       at System.Runtime.Serialization.XmlFormatReader.ReadCollectionItems(DeserializedObject desObj, CollectionDataContract collectionContract, Int32 membersRead, Int32 size)
       at System.Runtime.Serialization.XmlFormatReader.ReadCollection(DeserializedObject desObj, CollectionDataContract collectionContract, Int32 membersRead)
       at System.Runtime.Serialization.XmlFormatReader.Deserialize(XmlObjectSerializerReadContext context)
       at System.Runtime.Serialization.XmlFormatReader.InitializeCallStack(DataContract clContract, XmlReaderDelegator xmlReaderDelegator, XmlObjectSerializerReadContext xmlObjContext, XmlDictionaryString[] memberNamesColl, XmlDictionaryString[] memberNamespacesColl)
       at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
       at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)
       at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, DataContract& dataContract)
       at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)
       at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName)
       at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName)
       at System.Runtime.Serialization.XmlObjectSerializer.ReadObject(XmlDictionaryReader reader)
       at ...
       at Microsoft.Phone.Shell.PhoneApplicationService.FireLaunching()
       at Microsoft.Phone.Execution.NativeEmInterop.FireOnLaunching()


If you're not knowlingly deserializing any XML, then I can only guess that either:

  • the app's isolated storage contains some app-state XML (e.g. from AppSettings)
  • or that there's a problem with the configuration XML for your app

To try to fix this, you could:

  1. Take a look in the Properties folder of your project - are the XML configuration files there OK? If you open them in the editor, are there any warnings or errors shown?
  2. Uninstall the app from the emulator and/or from your phone (you can even try restarting the emulator or factory resetting the phone)

If not, post more info and we'll try to help more - interesting problem!


If you are working with WCF, this might be caused by added "IsReference=true" of the DataContract at server side. In actual payload it will be noticeable as something like z:Id=”i7”.

If you have two versions (one working and one not working) I would recommend to debug as deep as possible so you can clearly see stuff you deserialize, and then do text comparison of two versions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜