Проблема с сериализацией экземпляров класса в Xml

Рейтинг: 0Ответов: 1Опубликовано: 19.04.2015

Есть класс, экземпляр которого нужно перенести в XML файл. Однако возникает исключение

Первый этап обработки исключения типа "System.InvalidOperationException" в System.Xml.dll

Дополнительные сведения: Возникла ошибка при отражении типа "Lab2.Model.Circle".

public class Circle:Figure2D
    {
        private double r;
        public double R
        {
            set
            {
                if (value >= 0) this.r = value;
                else throw new ArgumentNullException("Wrong radius value ( value < 0 ? ) ");
            }
            get { return r; }


        }

        public override string Save()
        {
            string s = string.Format("Circle {0} {1} {2}",this.Center.X, this.Center.Y, this.R);
            return s;

        }
        public override double P()
        {
            return 2 * Math.PI * R;
        }
        public override double S()
        {
            return Math.PI * R * R;
        }

        public static Circle LoadCircle(string s)
        {
            string[] ss = s.Split(' ');
            int x = Convert.ToInt32(ss[1]);
            int y = Convert.ToInt32(ss[2]);
            int r = Convert.ToInt32(ss[3]);

            return new Circle(new Point(x, y), r);

        }
        public override void Draw(PaintEventArgs e)
        {
            e.Graphics.DrawEllipse(new Pen(Color.Black), (int)this.Center.X, (int)this.Center.Y, (int)this.R, (int)this.R);
        }
        public override void Zoom(double K, bool isfromImage)
        {
            this.R *= K;
            if(isfromImage)
            {
                this.Center.X *= K;
                this.Center.Y *= K;
            }
            Console.WriteLine("circle zoom of {0}", this.GetType());
        }

        public override string ToString()
        {
            string baseInfo = base.ToString();
            return baseInfo + string.Format("\n R: {0}\n", this.R);
        }

        public Circle() { }

        public Circle(Point Center, double R) : base(Center)
        {
            this.R = R;
        }

        public Circle(Circle other) : base(other.Center)
        {
            this.R = other.R;
        }
    }

Ответы

▲ 3

Спасибо @Memoizer. Посмотрев в innerException обнаружил что родительский класс не имеет открытый конструктор без параметров.