在用户更新了记录本身之后,我编写了一个插件来更新销售订单上的一些数据。根据是否更改了某些日期,我想用格式化日期更新另一个字段。
我遇到了错误“字典中不存在给定的键”,所以我添加了一些跟踪来查看它到底在哪里返回了错误。然后我发现跟踪从未写出,所以我假设我写的代码永远不会被执行。确实是这样,因为如果我这样做
public class SalesOrderPlugin : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
}
}
我犯了同样的错误:
Unhandled Exception: System.ServiceModel.FaultException`1
[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]:
Unexpected exception from plug-in (Execute): Iu.PreConsultants.Crm.SalesOrderPlugin:
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.Detail:
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
<ErrorCode>-2147220956</ErrorCode>
<ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Message>Unexpected exception from plug-in (Execute): Iu.PreConsultants.Crm.SalesOrderPlugin: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.</Message>
<Timestamp>2012-02-21T07:09:48.471378Z</Timestamp>
<InnerFault i:nil="true" />
<TraceText>
[Iu.PreConsultants.Crm: Iu.PreConsultants.Crm.SalesOrderPlugin]
[1486b5df-595c-e111-b7b0-46c950e6c8cd: Iu.PreConsultants.Crm.SalesOrderPlugin: Update of salesorder]
</TraceText>
</OrganizationServiceFault>
插件的设置:
- 验证后
- 同步执行模式
- 服务器部署
在托管设置上(沙盒)
SalesOrder 已更改并具有一些自定义属性。
对此的任何帮助将不胜感激!
亲切的问候,
文森特