Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 获取“无法隐式地将类型“Tables[]”转换为“Generic.List”_.net_Wcf_Visual Studio 2010_Visual Studio 2008 - Fatal编程技术网

.net 获取“无法隐式地将类型“Tables[]”转换为“Generic.List”

.net 获取“无法隐式地将类型“Tables[]”转换为“Generic.List”,.net,wcf,visual-studio-2010,visual-studio-2008,.net,Wcf,Visual Studio 2010,Visual Studio 2008,几年前,我编写了一个WCF服务,该服务在IIS下的Windows 2003服务器上运行。我使用VS 2008和.NET 3.5编写了该服务。相关代码如下: public static List<ASILookupTables> GetLookupTableAux(bool UseProduction) { ASIClassesDataContext dcASI = new ASIClassesDataContext(); var result = from lookups in d

几年前,我编写了一个WCF服务,该服务在IIS下的Windows 2003服务器上运行。我使用VS 2008和.NET 3.5编写了该服务。相关代码如下:

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;
}
现在我正在使用.NET 4.0编写一个VS 2010应用程序来使用它。VS 2010应用程序中有问题的代码片段如下:

            LookupSvc.LookupsClient proxy = new LookupSvc.LookupsClient();

        //retrieve list of lookup tables
        List<LookupSvc.ASILookupTables> lookupTables = proxy.GetLookupTableAux(true);
但是,我得到了以下错误:

无法将类型“AsiEF.LookupSvc.ASILookupTables[]”隐式转换为“System.Collections.Generic.List”


我不明白;在WCF代码中,我看起来像是在返回列表。它不像是在返回数组。这是因为WCF服务在.NET 3.5中,而我的新项目在.NET 4.0中吗?

如果希望代理使用列表或t[],可以更改服务引用设置


要更改设置,请右键单击解决方案资源管理器中项目中的服务引用。在集合类型中选择配置服务引用。选择系统。集合。通用。列表。

我有一个后续问题要问您。我在“服务引用设置”对话框中,现在可以看到您所指的集合类型。它是设置为System.Array,我可以按照您的建议将其设置为System.Collections.Generic.List。我想知道,我是否也应该选中“始终生成邮件合同”复选框?@Rod,通常不会。请看。您是一个传奇人物!!非常感谢您,已经给了u+1+,感谢Rod发布原始问题+1.: