没有代码的 CRM 2011 插件会返回“字典中不存在给定的键”
我编写了一个插件,用于在用户更新记录本身后更新销售订单上的一些数据。根据某些日期是否更改,我想用格式化日期更新另一个字段。
我遇到了错误“字典中不存在给定的键”,因此我添加了一些跟踪来查看它到底在哪里返回了错误。然后我发现跟踪从未写出,所以我假设我编写的代码永远不会被执行。确实如此,因为如果我这样做,
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 已更改并具有一些自定义属性。
对此的任何帮助将不胜感激!
亲切的问候,
文森特
I wrote a plugin to update some data on a salesorder, right after the user has updated the record itself. Based on whether certain dates were changed, I want to update another field with a formatted date.
I ran across the error "The given key was not present in the dictionary" so I added a few traces to see where it exactly returned the error. I then discovered that the trace never wrote out, so I assumed the code I wrote never gets executed. This is indeed the case because if I just do
public class SalesOrderPlugin : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
}
}
I get the same error:
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>
The settings for the plugin:
- Post-validation
- Synchronous execution mode
- Server deployment
On a hosted setup (sandboxed)
SalesOrder has been altered and has some custom attributes.
Any help on this would be greatly appreciated!
Kind regards,
Vincent
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,现在可以了。看来 glosrob 是对的,并且 CRM 保留了一个缓存版本。我尝试在 SDK 中的注册工具的 IPlugin 实现上使用“更新”,但这还不够。我必须首先更新程序集,然后 IPlugin 实现也得到更新。
Ok it works now. It seems like glosrob was right and there was a cached version kept by CRM. I tried to use "Update" on the IPlugin implementations on the registrationtool from the SDK but that wasn't sufficient. I had to Update the Assembly first, and after that, the IPlugin implementations also got updated.