WCF changing list type to arraylist, I tried to change in the advanced settings as well but still getting same error which convert List<T> to array []


I have WCF service:

[OperationContract(Name = "GetAllEmployee")]
IList<Employee> GetEmployees(string UserId, string UserPassword);

In ServiceWeb.svc.cs file, I have this code:

public IList<Employee> GetEmployees(string UserId, string UserPassword)
{
    List<Employee> E = new List<Employee>();
    return E;
}

Now, when I add this WCF reference to the web project, it gets converted to using []:

public ServiceWeb.ServiceProWCFService.Employee[] GetAllEmployee(string UserId, string UserPassword) 
{
    ServicePROWeb.ServiceProWCFService.GetAllEmployeeRequest inValue 
        = new ServicePROWeb.ServiceProWCFService.GetAllEmployeeRequest();

    inValue.UserId = UserId;
    inValue.UserPassword = UserPassword;

    ServicePROWeb.ServiceProWCFService.GetAllEmployeeResponse retVal =
        ((ServicePROWeb.ServiceProWCFService.IServiceProWCFService)(this))
            .GetAllEmployee(inValue);

    return retVal.GetAllEmployeeResult;
}

This is not correct. I tried to change in the advanced settings to make it as shown in this screenshot:

enter image description here

But it still didn’t change.

I have already tried these things:

  1. Change the advanced setting of the configure reference to make System.Collection.Generic.List and reload the service again, but it didn’t work

  2. Removed all the old references to the service and tried to do a generic list instead of an IEnumerable list for the return type.

Please suggest a better solution to handle this

Leave a Reply

Your email address will not be published. Required fields are marked *