I have a WCF Service (.NET4.0). Client is in .NET2.0. Enum values passed by the client into the service are always set with enum default value (which is the first enum member).
Is this an issue in .NET2.0 ? Are there any workarounds ?
I have a WCF Service (.NET4.0). Client is in .NET2.0. Enum values passed by the client into the service are always set with enum default value (which is the first enum member).
Is this an issue in .NET2.0 ? Are there any workarounds ?
Copyright © 2021 Jogjafile Inc.
The <FieldName>Specified is a feature used by the XmlSerializer. I've been stung by this before. It seams everyone finds out about this feature in a similiarly painful manner.
As you say, if this is set to false then your field won't be serialised. Unfortunatly false is the default for a boolean field so it can very annoying if you forget to set it.
If you do not appreciate this feature then you should be able to just delete the <FieldName>Specified field without consequence. Then the field will always be serialized.
These fields only make a difference because you are using the XmlSerializer in .NET 2. In your .NET 4 WCF app you are using the DataContractSerializer which does not possess this feature.
The default value of the enum is not really received by WCF. Really nothing is received on the server for that enum. Consequently the enum is not set, so it remains the default value.