【发布时间】:2013-12-22 07:05:57
【问题描述】:
此错误可能很常见,也可能出现在其他问题中,但我有一个奇怪的情况,我收到此错误消息
底层连接已关闭:连接已关闭 没想到
只有当我在服务中传递 DataTable 时才会收到此错误,但将其放入 DataSet 时不会收到此错误。
这几天我上网查了,但没找到背后的奥秘。
我只是怀疑 WCF 服务是否仅在容器类型中才接受数据。
[OperationContract]
DataSet GetCurrencyDetails(int CurrencyId); // No error for the service
[OperationContract]
DataTable GetCurrencyDetailsDataTable(int CurrencyId); //getting error for the same service
这里它们都返回相同的结果,但一个在 DataSet 中具有 DataTable,另一个直接在 DataTable 中。
在客户端代码是
UtilityClient client= new UtilityClient("BasicHttpBinding_IUtility");
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt = client.GetCurrencyDetailsDataTable(CurrencyId); //error at this point
ds =client.GetCurrencyDetails(CurrencyId); // no error here for dataset
我还检查了提到的内部异常,但它只有标题中描述的错误
这是查看详细信息中的错误详细信息
我希望我能找到解决方案。
谢谢。
【问题讨论】:
-
你能解决这个问题吗?
-
我正在继续使用 DataSet 本身来处理我的所有回复。 DataTable 正在获取我提到的错误。
标签: c# wcf datatable dataset runtime-error