1
Answer

Add method on Opertaion Contract

Photo of A D

A D

15y
2.9k
1

Hello,
I have created a windows service and I am having an issue calling a method to an external class. Here is my setup
[ServiceContract] 
[
ServiceKnownType(typeof(Customer))]
public interface ICustomerService 
{ 
 
     
[OperationContract] 
     
void PersistCustomer(Customer customer); 
} 

The Customer has get and set properties which have no difficulty setting, but the there is an Add method on customer that throws an NotSupportedException; "Collection was of fixed size",  each time I try to use it. The collection of "customers" is setup as an IList and excepts types ICustomer as I have defined. When I try using the Add method outside of my service I have no issues at all, which leads me to think I do not have something setup right on my ICustomerService. Can anyone help me with this issue please?
 

Answers (1)

0
Photo of A D
NA 12 0 15y
Ok. I think I have found my issue. I can not use IList because once the service gets a hold of the collection, it tries to interpret what IList is and fails horribly and I end with a System.Array instead what I sent across to the service. So the solution to my issue is to use List; concrete class, instead of IList. I believe and hope this issue is resolved in a later version of .NET.