[英]“ArrayOfKeyValueOfstringstringKeyValueOfstringstring[])' has some invalid arguments” in asp.net C#
在下面的代码中,我有一个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()));
}
}
看起来问题在于,当您导入服务引用时,映射词典时出了点问题。
或者,您可能已将其添加为Web参考而不是新的Service Reference 。
您可以尝试再次添加引用,并验证System.Collections.Generic.Dictionary
是使用的Dictionary
集合类型,并且Collection类型是 System.Collection.Generic.List
。
除此之外,您可以提供代理正在等待的确切对象,因此您的代码将如下所示:
using WebApp.MasterBiz;
//...
var GRNCostInVals = new ArrayOfKeyValueOfstringstringKeyValueOfstringstring[2];
GRNCostInVals[0] = new ArrayOfKeyValueOfstringstringKeyValueOfstringstring();
GRNCostInVals[0].Key = "GRNID";
GRNCostInVals[0].Value = hidGoodsReceivedNoteID.Value.ToString();
GRNCostInVals[1] = new ArrayOfKeyValueOfstringstringKeyValueOfstringstring();
GRNCostInVals[1].Key = "LoadingCost"
GRNCostInVals[1] = txtLoadingCost.Value.ToString();
//...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.