I have a simple wcf Service Contract that works fine if I use the concrete implementations for the interfaces, but if I want to use the interfaces in the paramaters instead of the concrete classes, it gives me the error which I will display below.
Here is code:
[ServiceContract]
public interface IClientUserRegistration
{
[OperationContract]
void RegisterClientUser(ClientUser clientUser);
[OperationContract]
List<ClientUser> GetUsers();
}
If I replace ClientUser with IClientUser, the WCF Test Client says that RegisterClientUser
operation is not supported because it uses the type System.Object. If I replace the return value of GetUsers with List, it says that this operation is not supported because it uses the type System.Object[]. Why does it give these errors?
The reason why I was trying to use IClientUser is that I could implement different user types that implement the IClientUser interface and pass them into RegisterClient, but if I am only able to pass ClientUser, then I have to create a bunch of RegisterClient overrides that take different types of Users.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…