A few years ago I wrote a WCF service, which runs on a Windows 2003 server under IIS. I wrote it using VS 2008, and .NET 3.5. The code in question is this:
public static List<ASILookupTables> GetLookupTableAux(bool UseProduction)
{
ASIClassesDataContext dcASI = new ASIClassesDataContext();
var result = from lookups in dcASI.ASILookupTables4s
orderby lookups.SortOrder
select lookups;
List<ASILookupTables> list = new List<ASILookupTables>();
foreach (var item in result)
{
ASILookupTables alt = new ASILookupTables();
//more lines to add other elements
list.Add(alt);
}
return list;
}
Now I’m writing a VS 2010 app, using .NET 4.0, to consume this. The code snippet in question in the VS 2010 app is this:
LookupSvc.LookupsClient proxy = new LookupSvc.LookupsClient();
//retrieve list of lookup tables
List<LookupSvc.ASILookupTables> lookupTables = proxy.GetLookupTableAux(true);
However, I’m getting the following error:
“Cannot implicitiy convert type ‘AsiEF.LookupSvc.ASILookupTables[]’ to ‘System.Collections.Generic.List'”
I don’t get it; in the WCF code it looks to me like I’m returning a list. It doesn’t look like I’m returning an array. Is it because the WCF service is in .NET 3.5 and my new project is in .NET 4.0?
You can change in the service reference settings if you want the proxy to use
List<T>orT[].To change the settings, right click the service reference in the project in solution explorer. Pick “Configure Service Reference”. In “Collection type” pick
System.Collections.Generic.List.