2013-04-25 70 views
0

我收到错误 “最佳重载的方法匹配具有一些无效参数”最佳重载方法匹配有一些无效参数Asp.net Wcf?

我的代码,

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\ 

,而我有以下的,

in

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 =新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是其的DatabaseManager dll是使用这个WCF项目,但其他一些项目,为什么它不recognizsing “inventoryproject”

希望你的帮助

回答

1

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

enter image description here

你所得到的错误的原因是,当你加入,你可能指定的服务基准,System.Collection.Generic.List作为集合类型。您可以将其修改为Array。

+0

非常感谢你的建议帮助我很多! – 2013-04-25 06:51:18

+0

还有一件事我想问,我得到的错误就像它一样 – 2013-04-25 06:52:22

+0

@testerJoe,请确保您的Web方法正在接受相同类型的参数,无论是列表还是数组。这将是更简单的你通过代理 – Habib 2013-04-25 06:53:36

相关问题