web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Plugin error

(1) ShareShare
ReportReport
Posted on by 155

I'm trying to debug a plugin by downloading the log file and attaching it to the plugin registration tool. I started the profiler and recreated the issue. I see that the error below : 

"Unexpected exception from plug-in (Execute): PluginProfiler.Plugins.ProfilerPlugin: System.Security.SecurityException: The data contract type 'Microsoft.Xrm.Sdk.OrganizationServiceFault' cannot be serialized in partial trust because the property 'ExceptionRetriable' does not have a public getter."

Any suggestions/Info on this?

Thank you.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mikhail.T Profile Picture
    12 on at
    RE: Plugin error

    Good day, colleagues,

    Had the same error. 

    For me, there were problems with a sandbox service. By default PluginProfiler DLL loads in a sandbox isolation mode. 

    Profiler DLL not acceptable in PluginRegistrationTool. So I found table PluginAssembleBase and changed IsolationMode to 1 for "PluginProfiler.Plugins" assembly. 

    That's made the deal for me, hope it helps someone. 

  • sai123456 Profile Picture
    324 on at
    RE: Plugin error

    My plugin was working good. I have added profiler and forgot to unprofile when unregistered the Assembly. Got this error when registered the plugin again.

    Removing the profiled step for last version of assembly resolved it for me.

  • Suresh_Satti Profile Picture
    205 on at
    RE: Plugin error

    Thank you All, i am not really sure what the problem was but when i tried the same code on new trial instance the code worked but gave an SQL error stating "Cannot use a CONTAINS or FREETEXT predicate on table" So i am guessing something was wrong with the previous instance and it couldnt handle the SQL error.

    About the SQL error, it was because the account table wasnt full text indexed. In a Microsoft Dynamics 365 default installation, only the attributes of the KBArticle (article) entity are enabled for full-text indexing.

    My issue got resolved by using LIKE instead of Contains.

  • Michel Gueli Profile Picture
    982 on at
    RE: Plugin error

    Can you tell me what the requirement is? Why update each account?

    I will also change this line: items.Attributes["new_countofallrecords"] = result.Entities.Count.ToString();

    OrgService.Update(items);

    Create a new entity object like this:

    var updateAccount = new Entity("account")";

    updateAccount .Id = items.Id;

    updateAccount.Attributes.Add("new_countofallrecords", result.Entities.Count.ToString());

    OrgService.Update(updateAccount);

  • Mir Hassan Ali Profile Picture
    1,720 on at
    RE: Plugin error

    Hi Suresh

    Can you try including the attribute 'new_countofallrecords' in your column set that you are retrieving.

    Mir

  • Suresh_Satti Profile Picture
    205 on at
    RE: Plugin error

    Sorry to say, it still dosent work. I continue to get the same error. Please see the below complete code that i ran.

    public class Class1 : IPlugin
    {
    public void Execute(IServiceProvider serviceProvider)
    {
    // Obtain the execution context from the service provider.
    var Context =
    (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

    // Get a reference to the Organization service.
    var factory =
    (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
    var OrgService = factory.CreateOrganizationService(Context.UserId);

    var query =
    new QueryExpression("account")
    {
    ColumnSet = new ColumnSet("name", "address1_city"),
    Criteria =
    {
    Conditions =
    {
    new ConditionExpression("address1_city", ConditionOperator.Contains, "Red")
    }
    }
    };
    var result = OrgService.RetrieveMultiple(query);

    foreach (var items in result.Entities)
    {
    items.Attributes["new_countofallrecords"] = result.Entities.Count.ToString();
    OrgService.Update(items);
    }
    }
    }
    }

  • Community Member Profile Picture
    on at
    RE: Plugin error

    Hi,

    try the following:

    public void Execute(IServiceProvider serviceProvider)
            {
                // Obtain the execution context from the service provider.
                Context =
                    (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
    
                // Get a reference to the Organization service.
                var factory =
                    (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                OrgService = factory.CreateOrganizationService(Context.UserId);
    
                var query =
                    new QueryExpression("account")
                    {
                        ColumnSet = new ColumnSet("name", "address1_city"),
                        Criteria =
                        {
                            Conditions =
                            {
                                new ConditionExpression("address1_city", ConditionOperator.Contains, "Red")
                            }
                        }
                    };
                var result = OrgService.RetrieveMultiple(query);
    
                foreach (var items in result.Entities)
                {
                    // do something
                }

    ......

    Set the breakpoint to the foreach, not the OrgService.Ret....

  • Suresh_Satti Profile Picture
    205 on at
    RE: Plugin error

    Still the same. See the below error.

    3302.error.png

  • Michel Gueli Profile Picture
    982 on at
    RE: Plugin error

    I've updated your code:

    var query = new QueryExpression("account");

    query.PageInfo.ReturnTotalRecordCount = true; //Why use this line????

    query.ColumnSet.AddColumn("name");

    query.ColumnSet.AddColumn("address1_city");

    query.Criteria.AddCondition("statecode", ConditionOperator.Equal, 0);

    query.Criteria.AddCondition("address1_city", ConditionOperator.Contains, "Red");

    EntityCollection results = service.RetrieveMultiple(query);

  • Suresh_Satti Profile Picture
    205 on at
    RE: Plugin error

    The commented part runs fine i.e. querybyattribute, but the rest is for Queryexpression that is what is problematic.

                   //QueryByAttribute query = new QueryByAttribute { EntityName = "account", ColumnSet = new ColumnSet("name", "address1_city") };

                   // query.AddAttributeValue("statecode", 0);

                   //query.PageInfo.ReturnTotalRecordCount = true;

                   ConditionExpression condition1 = new ConditionExpression();

                   condition1.AttributeName = "address1_city";

                   condition1.Operator = ConditionOperator.Contains;

                   condition1.Values.Add("Red");

                   FilterExpression filter1 = new FilterExpression();

                   filter1.Conditions.Add(condition1);

                   QueryExpression query = new QueryExpression("account");

                   query.ColumnSet.AddColumns("name", "address1_city");

                   query.Criteria.AddFilter(filter1);

                   EntityCollection results = service.RetrieveMultiple(query);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
Christoph Pock Profile Picture

Christoph Pock 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans