I need to return a complex type from a webservice and had constructed the class MyComplexType which implements the interface IMyComplexType. Now in my webservice I have a method that should return an object that implements IMyComplexType like so:
[WebMethod]
public IMyComplexType GetMyComplexType()
{
IMyComplexType myCt = new MyComplexType();
...
return myCt;
}
Everything compiles ok but when I run the webservice it throws an exception as follows:
System.NotSupportedException: Cannot serialize interface MyWebService.IMyComplexType.
Is this by design or am I missing something. Can I decorate my class or interface somehow to allow this? Do I have to eliminate all interfaces and only work with concrete and perhaps abstract base-classes to be able to do this with .net webservices?
Edit:
this is the interface I am trying to serialize:
public interface ICustomer
{
long Id {get; set;}
string Name {get; set;}
string EmailAddress {get; set;}
}