Skip to main content
Suggested answer

Unable to cast object of type to type at Microsoft.Xrm.Sdk.Entity.GetAttributeValue

editSubscribe (0) ShareShare
Posted on by 145


I am developing a plugin that has a post entity image called "image" , and i'm trying to access one of the crm fields in the relevant entity through this image , the field is called "test score" with schema "new_testscore", this field is floating number. I have generated an early bound entity classes with CrmSvcUtil.exe. but i'm facing this error:

System.InvalidCastException: Unable to cast object of type 'System.Decimal' to type 'System.Nullable`1[System.Double'. at Microsoft.Xrm.Sdk.Entity.GetAttributeValue[T(String attributeLogicalName) at Xrm.Incident.get_new_TestScore()

this is snapshot of my code:

var postImage = context.PostEntityImages["image"].ToEntity();
var testScore = postImage.new_TestScore;

Thank you.