System.NullReferenceException: Microsoft Dynamics CRM has experienced an error. -2147220970

Hi,

At times we have got this error while saving our record in CRM. It can occur if we have mistakenly registered steps of one of our plugins to some other plugins. Please check in plugin registration tool and delete those steps.

Hope it helps.

Advertisements

Plugin to check the InputParameters value of the Context in CRM 2011.

Hi,

Wrote a simple plugin to check the value of InputParameters being passed on update of lead record.

  public void Execute(IServiceProvider serviceProvider)
        {
            IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
            Entity myEntity = (Entity)context.InputParameters["Target"];
            // Get the attribute collection
            AttributeCollection myAttColl = myEntity.Attributes;
            // Write in a log file
            TextWriter log = TextWriter.Synchronized(File.AppendText(@"C:\InputParameterLog.txt"));

            log.WriteLine("Log generated at  " + DateTime.Now);
            log.WriteLine();

            foreach (KeyValuePair<string, object> myKV in myAttColl)
            {
                log.WriteLine("Key - " + myKV.Key);

                if (myKV.Value == null)
                {
                    log.WriteLine("Value - null");
                }
                else if (myKV.Value.GetType()== typeof(EntityReference))
                {
                    EntityReference eRef = myKV.Value as EntityReference;
                    log.WriteLine("Id - " + eRef.Id.ToString());
                    log.WriteLine("Logical Name - " + eRef.LogicalName);
                    log.WriteLine("Name - " + eRef.Name);
                }

                else if (myKV.Value.GetType() == typeof(OptionSetValue))
                {
                    OptionSetValue oSetValue = myKV.Value as OptionSetValue;
                    log.WriteLine("OptionSetValue - " + oSetValue.Value);
                }

                else
                {
                    log.WriteLine("Value - " + myKV.Value.ToString());
                }

                log.WriteLine();
            }
            log.WriteLine();
            log.Close();

        }

Haven’t tested it though, might be useful while debugging.

Bye.