views:

87

answers:

1

Is there a way to know how much space a serialized object transmitted in a WCF netTCP binding takes? I am getting a

The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.9570000'

error and I think that it may be due to the size of the datatable I am transmitting back. Is there a way in Windows debugger to determine how much space (bytes) the data to be transmitted back will take?

+1  A: 

Well, the easiest (and most accurate) option would probably be to set it to the max in the config (so it doesn't explode) and use WireShark to measure it during transmission; in theory you could use WCF message logging/tracing, but I've had hit-and-miss results when using that with large messages.

Alternatively, you could try using NetDataContractSerializer to write the data to a MemoryStream, and look at the .Length of the stream?

Note that if you are using classes (rather than DataTable), you might find another serializer helps; it isn't 100% scientific, but I recently compared NetDataContractSerialzier and protobuf-net.

Marc Gravell