I have a application that needs to serialize a custom object and send it to a windows service, the custom object contains 2 lists of custom objects and a dictionary of int, string. When i try to serialize the object I am getting the error message:
There was an error generating the XML document.
I've googled around and found that this is generally due to one of the datatypes not being setup for serialization correctly. So I've gone through and verified the serialization on all the custom classes and as far as I can tell it is setup correctly.
My question now is, are lists and dictionaries serializable by default or does something need to be done in order to serialize them? Or, is there a better way to serialize collections of custom objects to be passed between executables?
Edits:
Main Custom Class:
[Serializable]
class MoveInInfoRequest : ServerRequestData
{ }
[Serializable]
[XmlInclude(typeof(GetUnitTypesResponseData)), XmlInclude(typeof(VendorObj.RequiredFields)),
XmlInclude(typeof(VendorObj.InsuranceChoice)), XmlInclude(typeof(VendorObj.ProrateSettings))]
public class MoveInInfoResponse : ServerResponseData
{
public GetUnitTypesResponseData UnitTypesInfo
{ get; set; }
public List<VendorObj.RequiredFields> RequiredFields
{ get; set; }
public Dictionary<int, String> RentalPeriods
{ get; set; }
public List<VendorObj.InsuranceChoice> InsCoverageAmounts
{ get; set; }
public VendorObj.ProrateSettings ProrateOptions
{ get; set; }
}
Sampple Sub class: the other two classes are set up similar to this just much longer but they only use default datatypes.
<Serializable(), DataContract([Namespace]:="*companyNamespace*")> _
Public Class InsuranceChoice
Public Sub New()
End Sub
<DataMember()> _
Public InsuranceChoiceID As Integer
<DataMember()> _
Public CoverageDescription As String
<DataMember()> _
Public Premium As Decimal
<DataMember()> _
Public ActualCoverageAmount As Decimal
End Class