I have a class that I'm using as a DataContract. This class has a property that returns a string. It just so happens that this string includes XML (or, more correctly XHTML). Whenever I try to return an instance of this class, I get a ChannelIOException:
ChannelIOException: The underlying connection was closed: An unexpected error occurred on a receive.
Inner Exception: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
Inner Exception: An existing connection was forcibly closed by the remote host.
I have tried setting exceptions to break even when handled and I cannot find more information as to why it's crashing. I assume the serializer simply doesn't like XML in strings. What is the proper way to deal with this What if you don't know ahead of time that your string may or may not include XML
Regards,
Jared

XML in Strings
TWeiler
MaxMessageSize for this Channel (65536) has been exceeded.
I can probably find out how to fix this fairly quickly, but if someone knows please respond back.
Microsoft: Shouldn't the exception above have been propogated to the client instead of the vague underlying connection was closed exception that was actually thrown
六子
We are still working on the exception story -- it will be much improved in Beta2 and RTM.
As for your specific issue, you need to set the maxmessagesize for your binding to something higher -- or enabling streaming.
http://winfx.msdn.microsoft.com/library/default.asp url=/library/en-us/indigo_genref/html/85cf1a4f-26c2-48c7-bda6-6c960d5d3fb3.asp
highlights the first of these options...