Dynamics CRM 2016插件全局变量 [英] Dynamics CRM 2016 Plugin Global Variables

查看:179
本文介绍了Dynamics CRM 2016插件全局变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在Dynamics CRM 2016插件中增加了一个静态全局变量,它显示了如下所示的奇怪的随机模式。为什么它会显示奇怪的行为和模式?

I am simply incrementing a static global variable in a Dynamics CRM 2016 plugin and it shows strange random pattern as shown below. Why does it show strange behavior and pattern?

以下是我使用的代码。

 public class MyPlugin : IPlugin
{
    private static int count = 0;

    public void Execute(IServiceProvider serviceProvider)
    {

        try
        {
          if (_objContext.InputParameters.Contains("Target") &&     _objContext.InputParameters["Target"] is Entity)
            {
                WriteLog("Count value before increament: " + count,  service);
                count = count + 1;
                WriteLog("Count value after increament: "+count, service);
             }
         }
     }
  }


推荐答案

从外观来看,您有两个应用程序Web服务器,它们当前托管您的CRM实例(或者这些是异步插件,在这种情况下,您有两个异步服务器为您的CRM实例提供服务)有它自己的本地版本 MyPlugin.count ,这就是为什么你看到奇怪的行为。

From the looks of it, you have two Application webservers that are currently hosting your CRM instance (or these are async plugins, in which case, you have two async servers servicing your CRM instance) Each server has it's own local version of MyPlugin.count, which is why you're seeing the strange behavior.

应用程序CRM中的域名对于非垃圾邮件插件来说稍微简单一些,它是每个Crm Web服务器的一个。沙盒插件有点棘手。插件的每个注册步骤都有其独特的域。这需要CRM数据库(或CRM以外的其他东西)以保持这些值同步。

App Domains in CRM are a little bit simpler for unsandboxed plugins, it's one per Crm Web Server. Sandboxed plugins are a bit trickier. Each registration step of the plugin, has its own unique domain. This requires the CRM Database (or something else external to CRM) in order to keep these values in sync.

我创建了自动编号解决方案,它只使用CRM 2015中新增的版本功能,可以进行乐观的更新。但不幸的是,微软有一个bug,沙箱插件的Version#为空,所以它只能在内部环境中工作,直到bug解决。

I have created an auto-numbering solution that does do just that using the Version feature new in CRM 2015 that allows for optimistic updates. But unfortunetly, Microsoft has a bug where the Version # is null for sandboxed plugins, so it will only work in an on-prem environment, until the bug is resolved.

更新:该错误已得到解决。

Update: The bug has been resolved.

这篇关于Dynamics CRM 2016插件全局变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆