我嘗試使用下面的代碼保存在2011年CRM註釋實體:得到錯誤,同時節省註釋實體CRM
var annotationContext = new CrmOrganizationServiceContext(crmOrganizationService);
var annotation = annotationContext.CreateEntity("annotation");
annotationContext.AddObject(annotation);
// Setting the account id.
entity.SetAttributeValue<EntityReference>("objectid", "account", "Guid of the account");
entity.iCrmSetPropertyValue(AnnotationDefinition.ColumnsName.DocumentBody,Convert.ToBase64String(new UnicodeEncoding().GetBytes("Sample Annotation Text")));
entity.iCrmSetPropertyValue("isdocument",true);
entity.iCrmSetPropertyValue(AnnotationDefinition.ColumnsName.Mime, "text/plain");
entity.iCrmSetPickListValue(AnnotationDefinition.ColumnsName.ObjectType, 1);
entity.iCrmSetPropertyValue(AnnotationDefinition.ColumnsName.Subject, "CompanyLogo");
annotationContext.SaveChanges();
的更改保存方法失敗,並在CRM服務器的事件查看器下面的錯誤:
OrganizationId中的Web Service插件失敗:###########; SdkMessageProcessingStepId:#####; EntityName:註釋;階段:30; 消息名稱:Create;程序集名稱: Microsoft.Crm.Extensibility.InternalOperationPlugin, Microsoft.Crm.ObjectModel,Version = 5.0.0.0,Culture = neutral, PublicKeyToken = 31bf3856ad364e35; ClassName: Microsoft.Crm.Extensibility.InternalOperationPlugin;異常: 未處理的異常:System.InvalidCastException:指定的轉換爲 無效。在 Microsoft.Crm.BusinessEntities.EntityNameReferenceAttributeConverter.ConvertToBusinessEntity(對象 值,AttributeMetadata attributeMetadata,Dictionary`2 abbrvToChildAttributeMetadata,ICrmConversionContext上下文, 的BusinessEntity靶)在 Microsoft.Crm.BusinessEntities.EntityToBusinessEntityConverter.ConvertUsingExistingBusinessEntity(EntityMetadata entityMetadata,ICrmConversionContext conversionContext ,實體 實體,的BusinessEntity的businessEntity)在 Microsoft.Crm.BusinessEntities.BusinessEntity.Converter.ConvertFrom(ITypeDescriptorContext 上下文,CultureInfo的文化,對象值) Microsoft.Crm.BusinessEntities.ConversionHelpers.Convert(ICrmConversionCont分機 conversionContext,對象源,類型destinationType)在 Microsoft.Crm.Extensibility.DictionaryMapper.Map(ParameterCollection中 輸入,ICrmConversionContext上下文)在 Microsoft.Crm.Extensibility.InternalOperationPlugin.Execute(的IServiceProvider 的ServiceProvider)在 Microsoft.Crm .Extensibility.V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext 上下文)在 Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext 上下文)
你有類型衝突:'System.InvalidCastException:指定的轉換無效' – ccellar 2013-04-22 10:46:49
你實際發送''帳戶的指導?「或僅僅是爲了演示目的嗎? – 2013-04-22 21:09:05