0

我收到错误“最佳重载方法匹配有一些无效参数”

我的代码是,

System.Collections.Generic.List<ConsultantShares> consultantShareList = (Session["ProjectShare"] as List<ConsultantShares>);
        CIService.CIServiceClient client = new CIService.CIServiceClient();
        client.GetConsultantScoreAsync(consultantShareList,this.txtProjectId.Text,this.ddlWorkClass.SelectedValue);
        client.GetConsultantScoreCompleted += new EventHandler<CIService.GetConsultantScoreCompletedEventArgs>(client_GetConsultantScoreCompleted);

错误列表为,

Error   196 The best overloaded method match for
 'CIService.CIServiceClient.GetConsultantScoreAsync(InspectionServices.ConsultantShares[], string, string)'
 has some invalid arguments G:\Design Scoring\InspectionEvaluation\Summary.aspx.cs  32  
9   G:\Design Scoring\InspectionEvaluation\


Error   197 Argument 1: cannot convert from 'System.Collections.Generic.List<InspectionServices.ConsultantShares>' 
to 'InspectionServices.ConsultantShares[]'  G:\Design Scoring\InspectionEvaluation\Summary.aspx.cs  32  
40  G:\Design Scoring\InspectionEvaluation\

虽然我有以下内容,

namespace CIService

    {
        [GeneratedCode("System.ServiceModel", "4.0.0.0")]
        [DebuggerStepThrough]
        public class CIServiceClient : ClientBase<ICIService>, ICIService
        {
               public void GetConsultantScoreAsync(ConsultantShares[] cs, string targetProjectId, string workclass);
        public void GetConsultantScoreAsync(ConsultantShares[] cs, string targetProjectId, string workclass, object userState);
        }
    }

希望你的建议

谢谢

编辑:

出现错误

Error   30  The type or namespace name 'InventoryProject' does not exist in the namespace 'CIService' (are you missing an assembly reference?)  G:\Design Scoring\InspectionEvaluation\ProjectDetails.aspx.cs   108 23  G:\Design Scoring\InspectionEvaluation\

CIService.InventoryProject invProject = new CIService.InventoryProject();

而 CIService

 public InventoryProject GetInventoryProjectDetail(string consultantId, string projectId)
        {
            ProjectService prjService = new ProjectService();
            return prjService.GetInventoryProjectDetail(consultantId, projectId);
        }

 public List<InventoryProject> GetProjectsByConsultant(string consultantId, int currentPageNumber, int pageSize)
        {
            ProjectService prjService = new ProjectService();
            return prjService.GetProjectsByConsultant(consultantId, currentPageNumber, pageSize);
        }

而 CIService 是我的 WCF 服务,而 InventoryProject.datasource 是数据库管理器的其他一些项目,其 dll 正在此 wcf 项目中使用,但为什么它无法识别“inventoryproject”

希望能得到您的帮助

4

1 回答 1

1

你有两个选择。首先,您可以.ToList()在将方法作为参数传递给方法之前调用您的数组,第二个选项是您可以在创建代理时定义默认集合类型(添加服务引用)。

在此处输入图像描述

您收到错误的原因是,当您添加您可能指定的服务引用时,System.Collection.Generic.List作为 Collection 类型。您可以将其修改为数组。

于 2013-04-25T06:41:30.443 回答