[英]MS Dynamics CRM Plugin Error - [A]CrmWebSvc cannot be cast to [B]CrmWebSvc
I'm trying to create a simple Dynamics CRM plugin to create multiple entity association using Microsoft's XRM Tooling.我正在尝试创建一个简单的 Dynamics CRM 插件,以使用 Microsoft 的 XRM 工具创建多个实体关联。 I'm instantiating this class this way:
我正在以这种方式实例化这个类:
public class PartnerPlugin : IPlugin
{
public static IOrganizationService staticservice;
string log = string.Empty;
public void Execute(IServiceProvider serviceProvider)
{
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
CrmServiceClient crmService = new CrmServiceClient((OrganizationServiceProxy)serviceFactory.CreateOrganizationService(context.UserId));
...
}
}
It's almost the same code of another that i already have registered at CRM but this time it's giving me that error:它几乎与我已经在 CRM 注册的另一个代码相同,但这次它给了我这个错误:
[A]Microsoft.Xrm.Tooling.Connector.CrmWebSvc cannot be cast to [B]Microsoft.Xrm.Tooling.Connector.CrmWebSvc.
[A]Microsoft.Xrm.Tooling.Connector.CrmWebSvc 无法转换为 [B]Microsoft.Xrm.Tooling.Connector.CrmWebSvc。 Type A originates from 'plab_quote, Version=1.0.0.0, Culture=neutral, PublicKeyToken=567d876020387fa5' in the context 'LoadNeither' in a byte array.
类型 A 源自字节数组中上下文“LoadNeither”中的“plab_quote, Version=1.0.0.0, Culture=neutral, PublicKeyToken=567d876020387fa5”。 Type B originates from 'quotePartners, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4f3d8ebbe2fb8cfb' in the context 'LoadNeither' in a byte array.
类型 B 源自字节数组中上下文“LoadNeither”中的“quotePartners, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4f3d8ebbe2fb8cfb”。 If you contact support, please provide the technical details.
如果您联系支持,请提供技术细节。
The thing is that, after a lot of tests i just put these 3 lines of code (IPluginExecutionContext context = (...) CreateOrganizationService(context.UserId))) and nothing.问题是,经过大量测试后,我只放置了这 3 行代码 (IPluginExecutionContext context = (...) CreateOrganizationService(context.UserId))) 而什么都没有。 Same error.
同样的错误。 I'm using Dynamics CRM 365
我正在使用 Dynamics CRM 365
Another strange thing: I already had this error but, (i swear) i just took 5 minutes for a coffee and when i came back to try again the error was gone.另一件奇怪的事情:我已经遇到了这个错误,但是(我发誓)我只花了 5 分钟喝了杯咖啡,当我回来再试一次时,错误消失了。 I tried some coffee again but it's not working.
我再次尝试了一些咖啡,但它不起作用。 Nothing's working.
什么都不起作用。
Anyone?任何人? Any idea?
任何的想法?
Your plugin has two fields, staticservice
and log
.你的插件有两个字段,
staticservice
和log
。
Both fields (static as well as instance) are not thread safe.这两个字段(静态和实例)都不是线程安全的。 For every plugin class-stage-mode combination the system creates an instance that is being used for multiple, eventually concurrent events.
对于每个插件类-阶段-模式组合,系统都会创建一个用于多个最终并发事件的实例。
Race conditions will cause threads overwriting eachother's fields, which leads to unexpected results.竞争条件会导致线程覆盖彼此的字段,从而导致意外结果。
I finally realized that the problem is that i had already instancialized a variable with same name in another plugin with same step!我终于意识到问题是我已经用相同的步骤在另一个插件中实例化了一个同名的变量! That is the error :)
那是错误:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.