Serializing CommandBase derived object fails in WCF, but works with Web Service portal?

Serializing CommandBase derived object fails in WCF, but works with Web Service portal?

Old forum URL: forums.lhotka.net/forums/t/8409.aspx


rsbaker0 posted on Tuesday, January 26, 2010

In doing some pre-release testing, we've run into a class that functions properly when run with either the local or Web Service portal, but fails when run with the WCF portal.

The error being returned to the client is "The underlying connection was closed: The connection was closed unexpectedly".

I've debugged as far as I can in Visual Studio -- I've traced through the actual execution of the command.

An internal error is thrown in System.Data.DataTable.WriteXmlSchema (but is not returned as an inner exception)

System.InvalidOperationException occurred
Message="Cannot serialize the DataTable. DataTable name is not set."
Source="System.Data"
StackTrace:
at System.Data.DataTable.WriteXmlSchema(XmlWriter writer, Boolean writeHierarchy)
InnerException:

I can possibly see how to correct this from this description, but why would serialization fail here but work with the exact same object with the Web Service?

RockfordLhotka replied on Tuesday, January 26, 2010

The older data portal channels (everything except WCF) uses the BinaryFormatter to serialize the object graph into a byte stream.

The WCF channel lets WCF do the work, and so the NetDataContractSerializer is used.

The NDCS is 99.99% backward compatible with the BinaryFormatter. I don't have a list of the (very few) incompatibilities, but I'm told there are a couple obscure differences.

Perhaps you are hitting one of those obscure differences somehow?

rsbaker0 replied on Tuesday, January 26, 2010

OK, as long as these are "rare". I fixed this particular problem by taking a cue from the internally captured exception and providing a name for the DataTable.

Incidentally, I've found the WCF portal to be much more finicky about differences between object definitions (not that this is necessarily a bad thing). For example, I have some fields that are only defined in the debug build of a class and not the release build. The web service portal is quite happy to allow me to connect a debug version of the object with the release build of the data portal, but the WCF portal complains about field mismatch.

RockfordLhotka replied on Tuesday, January 26, 2010

This is all Msft code we're talking about here, so if the problems are too great you'll need to create a lower level repro and file the issue on connect as a .net bug.



-----Original Message-----
From: rsbaker0
Sent: January 26, 2010 7:21 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] Serializing CommandBase derived object fails in WCF, but works with Web Service portal?

OK, as long as these are "rare". I fixed this particular problem by taking a cue from the internally captured exception and providing a name for the DataTable.

Incidentally, I've found the WCF portal to be much more finicky about differences between object definitions (not that this is necessarily a bad thing). For example, I have some fields that are only defined in the debug build of a class and not the release build. The web service portal is quite happy to allow me to connect a debug version of the object with the release build of the data portal, but the WCF portal complains about field mismatche.

Copyright (c) Marimer LLC