HighTechTalks DotNet Forums  

XMLSerializer and List<T>

Dotnet XML microsoft.public.dotnet.xml


Discuss XMLSerializer and List<T> in the Dotnet XML forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Caspian
 
Posts: n/a

Default XMLSerializer and List<T> - 11-30-2007 , 08:40 AM






can anyone help with this problem, it seems to fail when I try to
initialise the XMLSerializer.

I'm getting a "There was an error reflecting type ... "

innerexception: "Cannot serialize member
'CommercialWebServices.DataAccess.ResponseStructur es.RequestParameters.Parameter'
of type 'System.Collections.Generic.List`

I'm trying to serialize the following ...

[Serializable]
public class RequestParameters
{

[XmlArray("Parameter")]
public List<oParameter> Parameter = new List<oParameter>();

public RequestParameters()
{
}
}

[Serializable]
public class oParameter
{
private string Parameter_ArgumentName;
private string Parameter_ArgumentValue;

[XmlAttribute("Name")]
public string Name
{
get { return Parameter_ArgumentName; }
set { Parameter_ArgumentName = value; }
}

[XmlAttribute("Value")]
public string Value
{

get { return Parameter_ArgumentValue; }
set { Parameter_ArgumentValue = value; }

}

public oParameter(string name, string value)
{
Parameter_ArgumentName = name;
Parameter_ArgumentValue = value;
}
}

.................................
I'm then trying to serialize the data with the following ...

try
{

RequestParameters testrequest = new
RequestParameters();

testrequest.Parameter.Add(new oParameter("Artist",
"Bob Marley"));
testrequest.Parameter.Add(new oParameter("Title", "No
Woman"));

XmlSerializer ser = new
XmlSerializer(typeof(RequestParameters));
XmlTextWriter writer = new XmlTextWriter("c:\
\RequestParameters.xml", System.Text.Encoding.UTF8);

}
catch (Exception ee)
{
Console.WriteLine(ee.Message);
}


Any help greatfully received,

Regards,

Tim

Reply With Quote
  #2  
Old   
Caspian
 
Posts: n/a

Default Re: XMLSerializer and List<T> - 11-30-2007 , 10:11 AM






I found problem ...

?ee.InnerException.InnerException.Message
"CommercialWebServices.DataAccess.ResponseStructur es.oParameter cannot
be serialized because it does not have a parameterless constructor."

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.