All I am trying to do is
XmlSerializer serializer = new XmlSerializer(typeof(Stack<int>));
and I get the following at runtime:
System.InvalidOperationException: You must implement a default accessor on System.Collections.Generic.Stack`1 [[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] because it inherits from ICollection.
Am I not supposed to serialize the Stack<int>?
Since the Stack class does not have a default accessor (by index for example) you cannot serialize it with that method.
I would suggest copying your stack to a List then serializing the list.
See if that doesn’t work better.