I'm trying to make a WCF call but I keep getting this error when the call returns to the client. I've tried setting all the decimal values to not-null values like so:
public IRecord SaveRecord(IRecord theRecord, string transactionId, bool reloadRecordAfterSave)
var retVal = GeneralServiceCalls.SaveRecord(theRecord, transactionId, reloadRecordAfterSave);
foreach (var property in retVal.GetType().GetProperties())
if (property.PropertyType == typeof(decimal) && property.GetValue(retVal) == null)
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:SaveRecordResult. The InnerException message was 'ValueType 'System.Decimal' cannot be null.'. Please see InnerException for more details.
System.Runtime.Serialization.SerializationException: ValueType 'System.Decimal' cannot be null.
at ReadAssetCustomFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString , XmlDictionaryString )
This exception was caused by the serializer of the message not having the same dll as the deserializer.
In this case, the class was outdated and as a result, the sender (serializer) serialized an object that didn't have the decimal field on it that the receiver (deserializer) was expecting and the exception was thrown.
I'm unsure as to why the WCF connection was even allowed to occur but I guess that's just how WCF works.