Why can't I serialize strings, points, and datatimes? RRS feed

  • Question

  • I was moving some classes to a class library and it's probably refreshes the compiler because now it generates all sort of warning  about my serializable class properties, the following properties gives a warning:

     public Point Location { get; set; } = new Point(0, 0);
            public DateTime HiredTime { get; set; } = DateTime.Now;
            public List<string> RoleTags { get; set; } = new List<string>();
            public List<string> ProffesionTags { get; set; } = new List<string>();
            public string Description { get; set; } = String.Empty;
    public string FirstName { get; set; } = String.Empty;
            public string LastName { get; set; } = String.Empty;

    the warning are:

    Field Location is a member of type (The main class ) which is serializable but is of type System.Drawing.Point which is not serializable

    and same for all the rest of the properties.

    I have noticed that type point is not serializing, but string and datetime seem to sterilize well so far, so why there are warnings? Did I broke something by moving the classes to a class library?

    • Edited by avivgood Monday, October 21, 2019 2:35 PM
    Monday, October 21, 2019 2:30 PM

All replies

  • Try this 

    public class Birthdays
      public DateTime DateOfBirth {get;set;}
      public string Name {get;set;}


    <?xml version="1.0" encoding="utf-16"?>
    <Birthdays xmlns:xsi="" xmlns:xsd="">
      <Name>John Smith</Name>


    See also

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    profile for Karen Payne on Stack Exchange

    Monday, October 21, 2019 3:35 PM
  • Hi avivgood,

    Thank you for posting here.

    Besed on your code, I try to serialize this object into JSON and XML files, but it works well without any warnings or errors.

    So could you provide more information so that I can reproduce your problem?

    Looking forward to your reply.

    Best regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Tuesday, October 22, 2019 8:10 AM