I have a problem trying to serialize a class into XML using the xmlserializer class. The error reads:
There was an error reflecting type 'MyApplication.UserManagement'.
The debugger highlights this particular section of code:
XmlSerializer serializer = new XmlSerializer(typeof(UserManagement));
Would I be right in saying that all members in the class I want to serialize as well have to be public? I thought this could be achieved by using properties without being forced to make all the members you want to serialize public.
To help with the understanding as well I'll quickly explain the structure of the program.
1. There is a User class containing details relating to a user such as user name, date of creation etc.
2. The users are contained within a list called usersList in the UserManagement class, which also contains other members such as lastActiveUser.
3. I am trying to serialize in XML the UserManagement class, this is done in a static class I have called DataManagement which contains the following code to serialize a UserManagement instance:
public static void SerializeUserManagementXML(object obj, string pathName, string fileName)
string fullPathName = Path.Combine(pathName, fileName);
XmlSerializer serializer = new
StreamWriter writer = new StreamWriter(fullPathName);
EDIT: Sorry I originally posted the wrong error message.
Any help is much appreciated!