在下面的代码中,我有一个 wcf 方法和void方法。当我执行它时,它会抛出错误
“错误170最佳重载方法匹配 'WebApp.MasterBiz.MastersClient.UpdateOtherExpenseCost(WebApp.MasterBiz.ArrayOfKeyValueOfstringstringKeyValueOfstringstring [])' 有一些无效的参数“
请帮我解决这个问题。
虚空方法:
Dictionary<string, string> GRNCostInVals = new Dictionary<string, string>();
GRNCostInVals.Add("GRNID", hidGoodsReceivedNoteID.Value.ToString());
GRNCostInVals.Add("LoadingCost", txtLoadingCost.Value.ToString());
GRNCostInVals.Add("UnloadingCost", txtUnloadingCost.Value.ToString());
GRNCostInVals.Add("InsuranseCost", txtInsuranseCost.Value.ToString());
GRNCostInVals.Add("MiscCost", txtMiscCost.Value.ToString());
GRNCostInVals.Add("MiscDescription", txtMiscDesc.Value.ToString());
GRNCostInVals.Add("TransporterBillNo", txtTransporterBillNo.Value.ToString());
GRNCostInVals.Add("TransporterBillDate", txtTransporterBillDate.Value.ToString());
GRNCostInVals.Add("FreightCharges", txtTranspotationCost.Value.ToString());
objCost.UpdateOtherExpenseCost(GRNCostInVals);
WCF方法:
public int UpdateOtherExpenseCost(Dictionary<string, string> objCost)
{
try
{
SqlParameter[] SqlParam = new SqlParameter[9];
SqlParam[0] = new SqlParameter("@i_GRNID", SqlDbType.Int);
SqlParam[0].Value = objCost["GRNID"];
SqlParam[1] = new SqlParameter("@nu_LoadingCost", SqlDbType.Float);
SqlParam[1].Value = float.Parse(objCost["LoadingCost"]);
SqlParam[2] = new SqlParameter("@nu_UnloadingCost", SqlDbType.Float);
SqlParam[2].Value = float.Parse(objCost["UnloadingCost"]);
SqlParam[3] = new SqlParameter("@nu_MiscCost", SqlDbType.Float);
SqlParam[3].Value = float.Parse(objCost["MiscCost"]);
SqlParam[4] = new SqlParameter("@vc_MiscDesc", SqlDbType.VarChar, 200);
SqlParam[4].Value = objCost["MiscDescription"];
SqlParam[5] = new SqlParameter("@nu_InsuranseCost", SqlDbType.Float);
SqlParam[5].Value = float.Parse(objCost["InsuranseCost"]);
SqlParam[6] = new SqlParameter("@vc_TransporterBillNo", SqlDbType.VarChar, 50);
SqlParam[6].Value = objCost["TransporterBillNo"];
SqlParam[7] = new SqlParameter("@dt_TransporterBillDate", SqlDbType.DateTime);
SqlParam[7].Value = DateTime.Parse(objCost["TransporterBillDate"]);
SqlParam[8] = new SqlParameter("@nu_TransportationCost", SqlDbType.Float);
SqlParam[8].Value = float.Parse(objCost["FreightCharges"]);
SqlHelper SqlHelp = new SqlHelper();
return SqlHelp.ExecuteNonQuery(SqlParam, "Sp_UpdateOtherExpenseCost");
}
catch (Exception ex)
{
GmasSupportException GmasSupportEx = new GmasSupportException();
GmasSupportEx.ExceptionType = ex.GetType().ToString();
GmasSupportEx.Message = ex.Message.ToString();
if (ex.InnerException != null)
GmasSupportEx.InnerExceptionMessage = ex.InnerException.Message;
throw new FaultException<GmasSupportException>(GmasSupportEx, new FaultReason(ex.Message.ToString()));
}
}
答案 0 :(得分:0)
看起来问题是,当您导入服务参考时,在映射词典时出现了问题。
或者您可能已将其添加为 Web Reference ,而不是新的服务参考。
您可以尝试重新添加引用并验证System.Collections.Generic.Dictionary
使用的Dictionary
集合类型以及集合类型是 {{ 1}}。
除此之外,您可以提供代理正在等待的确切对象,因此您的代码将如下所示:
System.Collection.Generic.List