It seems to me that you saved the results of calling the enumerator method without converting the result to a list.
If you have a method like this:
public IEnumerable<string> GetMyWidgetNames() { foreach (var x in MyWidgets) { yield return x.Name; } }
The compiler turns this into a nested object with a name similar to the one you see (with a name that you can never create because of the built-in + )
If you then keep the reference to this object inside of what you are trying to serialize, you will get the exception indicated by the OP.
Fix β Make sure your serialized objects always convert any IEnumerable <> lists to lists. Instead of this
public IEnumerable<string> WidgetNames { get; set; }
you need to write:
public IEnumerable<string> WidgetNames { get { return mWidgetNames; } set { if (value == null) mWidgetNames= null else mWidgetNames= value.ToList(); } } private List<string> mWidgetNames;
source share