2013-04-25 48 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

相關問題