I'm trying to update the invoice field "freightamount" from my C# code. I'm able to update other fields well like strings and Guid but for Money I get this error on creating or updating the invoice entity:
There was an error while trying to serialize parameter
http://schemas.microsoft.com/xrm/2011/Contracts/Services:entity. The InnerException
message was 'Type 'Microsoft.Xrm.Sdk.Money' with data contract name
'Money:http://schemas.microsoft.com/xrm/2011/Contracts' is not expected. Consider using a
DataContractResolver or add any types not known statically to the list of known types -
for example, by using the KnownTypeAttribute attribute or by adding them to the list of
known types passed to DataContractSerializer.'. Please see InnerException for more
details.
Here's a part of my code:
I use the reference to "Microsoft.Xrm.Sdk
"
Then in code:
invoice.Attributes.Add(new KeyValuePair<string, object>("freightamount", new Microsoft.Xrm.Sdk.Money (row.amount)));
Where row.amount
is a decimal value.