Scenario I have a WebService(.asmx) in C#.Net. I included a class which inherits from SoapHeader
class. I have a parameterized constructor in it but as I forgot to include a parameterless constructor, it generated following error when I updated the WebService proxy on client side:
Error: User cannot be serialized because it does not have a parameterless constructor.
So I immediately included the parameterless constructor and the issue ended up.
Questions
Q1. I think serialization takes place during request and response, Is it the 'class type' being serialized here (which I don't think is possible as its object which is serialized)?
Q2. I am not able to access Parameterized constructor (gives error: Does not contain a constructor that takes 1 argument ) on client side. Why is that?
Its a simple class for learning purpose:
public class User : SoapHeader
{
private string strUid;
public User(string id) // cannot access
{
strUid = id;
}
public User() { } // included later
public string UserID
{
get
{
return strUid;
}
set
{
strUid = value;
}
}
}