Click here to Skip to main content
15,071,399 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this operation is not supported in wcf test client because it uses type

svc file code

public System.Data.DataTable PendingCustomerViewAll()
DataTable tbl = new DataTable();

PendingBillSP sp = new PendingBillSP();
tbl = sp.PendingCustomerViewAll();
//DataSet ds = new DataSet();

catch (Exception)
return tbl;



DataTable PendingCustomerViewAll();

What I have tried:

how to use DataTable In wcf services the code is not running having error
Updated 25-Mar-16 2:38am

1 solution

Returning DataTables (or DataSets) from WCF-Services is typically not a very good idea, for various reasons. The two most prominent ones being:
1) Clients other than .NET can't deal with it.
2) The default serialization performance is really bad.
Further reading: c# - Returning DataTables in WCF/.NET - Stack Overflow[^]

In general it does work though and, to be honest, I don't know from the top of my head what could be the cause of your problem.

But: If you're okay with clients having to be .NET then solving the second issue (serialization performance) will also solve your current problem here.

I'm using this library for serializing DataTables: GitHub - rdingwall/protobuf-net-data: A library for serializing ADO.NET DataTables and DataReaders into a portable binary format.[^]

With it you can serialize a DataTable into a byte-array (and deserialize it) independently from WCF. The return type of your WCF-method then would be byte[] instead of DataTable and WCF has no problem with that. Also the serialization performance is way better than the default one, both in speed as well as in size.

If you want to make it a bit prettier than using byte[] as the return type then you could create a custom class which holds the serialized DataTable and make that class the return type of your WCF-method. Benefit being that the name of the class type better describes the semantic content of the return value than byte[] if you name it "SerializedDataTable", for example. You could also put the required code for serialization and deserialization of the DataTable into that class so that it's nicely encapsulated.
Sergey Alexandrovich Kryukov 25-Mar-16 10:09am
Sascha Lefèvre 25-Mar-16 10:41am
Thank you, Sergey.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900