WcfPortal and Serialization

WcfPortal and Serialization

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

maxal posted on Thursday, November 04, 2010

Please, help me with my confusion. Csla ver. 4.0.

I am looking at IWcfDataPortal and see that all methods have attribute [UseNetDataContract]. I assume it means everything, including my objects serialized using NetDataContractSerializer.

Am I right that BinaryFormatter serialization has nothing to do with this?

I noticed this http://social.msdn.microsoft.com/Forums/en/wcf/thread/2a78d0a8-2499-4817-a67b-d53dfb4afdeb problem with our enums, that's made us look into all this. Apparently the same problem exists for NetDataContractSerializer and DataContractSerializer.


RockfordLhotka replied on Thursday, November 04, 2010

Yes, when using WCF the data portal uses NetDataContractSerializer. DataContractSerializer doesn't have sufficient features to meet the requirements of the data portal, so I force the use of NDCS.

Those are the only serializers supported by WCF. Certainly you could use the BinaryFormatter manually and use WCF to pass a byte array back and forth. That byte array would, of course, be serialized with the DCS or NDCS :)

What specific problem are you having with passing enum values through the data portal? To my knowledge they work fine?

rfcdejong replied on Friday, November 05, 2010

Enum's work fine, when u make sure there is a 0 value inside like this:

public enum MyEnum
   NotSet = 0,
   Yes = 1,
   No = 2

maxal replied on Monday, November 08, 2010

Thank you for reply.

Somehow I had an impression that this is what was done inside, BinaryFormatter and byte array. Obviously, I was wrong. As was mentioned by [rfcdejong] below, the problem was with enumerator that had integer values defined, but no value for zero. Found this in one of the enumerators we were reusing from another project. The fix with dummy zero value works.

Copyright (c) Marimer LLC