So i made a contract class
[DataContractAttribute]
class contract
{
str firstname;
str lastname;
[DataMemberAttribute('firstname')]
public str firstname(str _firstname = firstname)
{
firstname = _firstname;
return firstname;
}
[DataMemberAttribute('lastname')]
public str lastname(str _lastname = lastname)
{
lastname = _lastname;
return lastname;
}
}
Now i did the following:
contract contract = new contract();
c.firstName("firstname");
c.lastname("lastname");
System.Xml.Serialization.XmlRootAttribute xmlRoot = new System.Xml.Serialization.XmlRootAttribute("root");
System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(contract.GetType(),xmlRoot); // I'm getting an error here: There was an error reflecting type 'Dynamics.AX.contract'. and another error :cannot be serialized because it does not have a parameterless constructor
what should i do to remove this error?
and what do more to be able to get a string of the XML format, there is serializer.serialize(//what to use here)