System.InvalidOperationException: ... cannot be serialized because it does not have a parameterles..
I'm trying to make an AOT class library, but I am unable to run it once compiled.
Here's the bit of code it doesn't like and the full error:
13 Replies
The error is telling you exactly what the issue is. The type you are trying to serialize needs a parameterless constructor
Because the serializer uses that to construct an empty instance and then set the properties / fields.
do I not have one right there tho?
The type in the error is TMXMap not TMXParser
I don't think TMXMap has a constructor tho
That's exactly why you're getting the error.
It doesn't have one. But if you want to serialize it, it has to have one.
so I just can't use that library at all?
I take it that it's not something you wrote yourself?
correct
If you don't own the type and it doesn't provide a parameterless constructor, I don't think there is a good way for you to serialize it with XmlSerializer.
oh
so I just.. can't do it?
I'm not sure what your code actually does, but the error says you are trying to serialize that type with XmlSerializer and that is simply not possible.
ah
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.