-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot cast XML to RealmObject #1913
Comments
Sounds like you can't use XmlSerializer as that doesn't allow you to ignore all properties by default (i.e. use an opt-in behavior as opposed to opt-out). You can instead use the DataContractSerializer and decorate your models with |
The problem is that the XML serializer tries to serialize the properties on the base @Doxoh according to this StackOverflow answer it should be possible to configure the XML serializer to ignore some properties. Perhaps you could configure it to ignore the properties on |
@nirinchev @fealebenpae Type 'BAAS.Model.Telegram' cannot inherit from a type that is not marked with DataContractAttribute or SerializableAttribute. Consider marking the base type 'Realms.RealmObject' with DataContractAttribute or SerializableAttribute, or removing them from the derived type. Did you have for this an idea? I didn't find an option for this. |
Hello,
i want to to XmlSerializer to get the XML as object.
I use this function.
By calling the Constructor I get the following error.
The model Telegram is not an IEnumerable or has a IEnumerable in it
{System.InvalidOperationException: There was an error reflecting type 'BAAS.Model.Telegram'. ---> System.InvalidOperationException: To be XML serializable, types which inherit from IEnumerable must have an implementation of Add(Realms.Schema.Property) at all levels of their inheritance hierarchy. Realms.Schema.ObjectSchema does not implement Add(Realms.Schema.Property).
at System.Xml.Serialization.TypeData.get_ListItemType () [0x00209] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System.XML/System.Xml.Serialization/TypeData.cs:395
at System.Xml.Serialization.TypeData.get_ListItemTypeData () [0x00016] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System.XML/System.Xml.Serialization/TypeData.cs:336
at System.Xml.Serialization.TypeData..ctor (System.Type type, System.String elementName, System.Boolean isPrimitive, System.Xml.Serialization.TypeData mappedType, System.Xml.Schema.XmlSchemaPatternFacet facet) [0x000dd] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System.XML/System.Xml.Serialization/TypeData.cs:115
at System.Xml.Serialization.TypeData..ctor (System.Type type, System.String elementName, System.Boolean isPrimitive) [0x00000] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System.XML/System.Xml.Serialization/TypeData.cs:86
at System.Xml.Serialization.TypeTranslator.GetTypeData (System.Type runtimeType, System.String xmlDataType, System.Boolean underlyingEnumType) [0x00294] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs:208
at System.Xml.Serialization.TypeTranslator.GetTypeData (System.Type type) [0x00000] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs:130
at System.Xml.Serialization.XmlReflectionImporter.GetReflectionMembers (System.Type type) [0x00258] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs:771
at System.Xml.Serialization.XmlReflectionImporter.ImportClassMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace, System.Boolean isBaseType) [0x00078] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs:346
at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00066] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs:215
at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x0011d] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs:235
at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00041] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs:190
at System.Xml.Serialization.XmlSerializer..ctor (System.Type type, System.Xml.Serialization.XmlAttributeOverrides overrides, System.Type[ ] extraTypes, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00041] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs:239
at System.Xml.Serialization.XmlSerializer..ctor (System.Type type, System.Xml.Serialization.XmlRootAttribute root) [0x00000] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/
…
The text was updated successfully, but these errors were encountered: