I am trying to pass a list object of type List<UploadQueue> to a WCF SOAP
method of the same parameter type and I am getting the error:
Cannot Convert from
‘System.Collections.Generic.List’
to ‘WebAPI.Upload.UploadQueue[]’
I don’t understand this because my WCF method’s (below) parameter type is List<UploadQueue>:
IService.DoUpload(List<UploadQueue> request)
Here is the code that calls “DoUpload” which returns the above error.
List<UploadQueue> results = new List<UploadQueue>();
HttpPostedFile m_objFile = default(HttpPostedFile);
int m_objFlag = default(int);
Guid m_objGuid = Guid.NewGuid();
DateTime m_objDate = DateTime.Now;
try
{
if (Request.Files.Count > 0)
{
for (var j = 0; i <= (Request.Files.Count - 1); j++)
{
m_objFile = Request.Files[j];
if (!(m_objFile == null | string.IsNullOrEmpty(m_objFile.FileName) | m_objFile.ContentLength < 1))
{
results.Add(new UploadQueue(
m_objGuid,
m_objFlag,
m_objFile.ContentLength,
m_objFile.FileName,
m_objDate)
);
}
}
}
}
catch (Exception ex)
{
//handle error
}
retParam = upload.DoUpload(results);
Ideas? Thanks.
In your client project, you need to right click on the service reference and select “Configure Service Reference”. On configuration screen, in the Data Type section, you need to set the collection type to System.Collections.Generic.List instead of System.Array.