Returning DataTable objects with WCF service

后端 未结 3 1590
感动是毒
感动是毒 2020-12-21 00:44

This is a strange problem that I am having with WCF trying to send DataTable in the response. I have the following service contract:

[ServiceContract]
public         


        
3条回答
  •  甜味超标
    2020-12-21 01:00

    While I admit that sending DataSets and DataTables via services is BAD and I actually have changed it so I am not doing so, the root of the problem lied elsewhere.

    For those that absolutely HAVE to use DataTables/DataSets, the error I was getting was because I was trying to send a DbNull object. I guess it is not serializable or there is some other reason it refused to send it.

    After manually "converting" DbNull into null (I had to do this to extract data into my own custom DataContract anyways), the error was gone and it worked!

提交回复
热议问题